當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.Endpoints方法代碼示例

本文整理匯總了Golang中github.com/qingyuancloud/QingYuan/pkg/client.Client.Endpoints方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Endpoints方法的具體用法?Golang Client.Endpoints怎麽用?Golang Client.Endpoints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/qingyuancloud/QingYuan/pkg/client.Client的用法示例。


在下文中一共展示了Client.Endpoints方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: runMasterServiceTest

func runMasterServiceTest(client *client.Client) {
	time.Sleep(12 * time.Second)
	svcList, err := client.Services(api.NamespaceDefault).List(labels.Everything())
	if err != nil {
		glog.Fatalf("unexpected error listing services: %v", err)
	}
	var foundRW bool
	found := util.StringSet{}
	for i := range svcList.Items {
		found.Insert(svcList.Items[i].Name)
		if svcList.Items[i].Name == "qingyuan" {
			foundRW = true
		}
	}
	if foundRW {
		ep, err := client.Endpoints(api.NamespaceDefault).Get("qingyuan")
		if err != nil {
			glog.Fatalf("unexpected error listing endpoints for qingyuan service: %v", err)
		}
		if countEndpoints(ep) == 0 {
			glog.Fatalf("no endpoints for qingyuan service: %v", ep)
		}
	} else {
		glog.Errorf("no RW service found: %v", found)
		glog.Fatal("QingYuan service test failed")
	}
	glog.Infof("Master service test passed.")
}
開發者ID:qingyuancloud,項目名稱:qingyuan,代碼行數:28,代碼來源:integration.go

示例2: endpointsSet

func endpointsSet(c *client.Client, serviceNamespace, serviceID string, endpointCount int) wait.ConditionFunc {
	return func() (bool, error) {
		endpoints, err := c.Endpoints(serviceNamespace).Get(serviceID)
		if err != nil {
			glog.Infof("Error getting endpoints: %v", err)
			return false, nil
		}
		count := 0
		for _, ss := range endpoints.Subsets {
			for _, addr := range ss.Addresses {
				for _, port := range ss.Ports {
					count++
					glog.Infof("%s/%s endpoint: %s:%d %#v", serviceNamespace, serviceID, addr.IP, port.Port, addr.TargetRef)
				}
			}
		}
		return count == endpointCount, nil
	}
}
開發者ID:qingyuancloud,項目名稱:qingyuan,代碼行數:19,代碼來源:integration.go

示例3: validateEndpointsOrFail

func validateEndpointsOrFail(c *client.Client, ns, serviceName string, expectedEndpoints map[string][]int) {
	By(fmt.Sprintf("Validating endpoints %v with on service %s/%s", expectedEndpoints, ns, serviceName))
	for {
		endpoints, err := c.Endpoints(ns).Get(serviceName)
		if err == nil {
			By(fmt.Sprintf("Found endpoints %v", endpoints))

			portsByIp := getPortsByIp(endpoints.Subsets)

			By(fmt.Sprintf("Found ports by ip %v", portsByIp))
			if len(portsByIp) == len(expectedEndpoints) {
				expectedPortsByIp := translatePodNameToIpOrFail(c, ns, expectedEndpoints)
				validatePortsOrFail(portsByIp, expectedPortsByIp)
				break
			} else {
				By(fmt.Sprintf("Unexpected number of endpoints: found %v, expected %v (ignoring for 1 second)", portsByIp, expectedEndpoints))
			}
		} else {
			By(fmt.Sprintf("Failed to get endpoints: %v (ignoring for 1 second)", err))
		}
		time.Sleep(time.Second)
	}
	By(fmt.Sprintf("successfully validated endpoints %v with on service %s/%s", expectedEndpoints, ns, serviceName))
}
開發者ID:qingyuancloud,項目名稱:qingyuan,代碼行數:24,代碼來源:service.go

示例4:

							{
								IP: serverIP,
							},
						},
						Ports: []api.EndpointPort{
							{
								Name:     "gluster",
								Port:     24007,
								Protocol: api.ProtocolTCP,
							},
						},
					},
				},
			}

			endClient := c.Endpoints(config.namespace)

			defer func() {
				if clean {
					endClient.Delete(config.prefix + "-server")
				}
			}()

			if _, err := endClient.Create(&endpoints); err != nil {
				Failf("Failed to create endpoints for Gluster server: %v", err)
			}

			volume := api.VolumeSource{
				Glusterfs: &api.GlusterfsVolumeSource{
					EndpointsName: config.prefix + "-server",
					// 'test_vol' comes from contrib/for-tests/volumes-tester/gluster/run_gluster.sh
開發者ID:qingyuancloud,項目名稱:qingyuan,代碼行數:31,代碼來源:volumes.go


注:本文中的github.com/qingyuancloud/QingYuan/pkg/client.Client.Endpoints方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。