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


Golang etcdserverpb.NewClusterClient函數代碼示例

本文整理匯總了Golang中github.com/coreos/etcd/etcdserver/etcdserverpb.NewClusterClient函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewClusterClient函數的具體用法?Golang NewClusterClient怎麽用?Golang NewClusterClient使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: memberListCommandFunc

// memberListCommandFunc executes the "member list" command.
func memberListCommandFunc(cmd *cobra.Command, args []string) {
	endpoint, err := cmd.Flags().GetString("endpoint")
	if err != nil {
		ExitWithError(ExitError, err)
	}
	conn, err := grpc.Dial(endpoint)
	if err != nil {
		ExitWithError(ExitBadConnection, err)
	}
	mc := pb.NewClusterClient(conn)

	resp, err := mc.MemberList(context.TODO(), &pb.MemberListRequest{})
	if err != nil {
		ExitWithError(ExitError, err)
	}

	// use https://github.com/olekukonko/tablewriter to print out a pretty table?
	for _, m := range resp.Members {
		if len(m.Name) == 0 {
			fmt.Printf("%16x[unstarted]: peerURLs=%s\n", m.ID, strings.Join(m.PeerURLs, ","))
		} else {
			fmt.Printf("%16x: name=%s peerURLs=%s clientURLs=%s\n", m.ID, m.Name, strings.Join(m.PeerURLs, ","), strings.Join(m.ClientURLs, ","))
		}
	}
}
開發者ID:rtewalt,項目名稱:etcd,代碼行數:26,代碼來源:member_command.go

示例2: newClient

func newClient(cfg *Config) (*Client, error) {
	if cfg == nil {
		cfg = &Config{RetryDialer: dialEndpointList}
	}
	var creds *credentials.TransportAuthenticator
	if cfg.TLS != nil {
		tlscfg, err := cfg.TLS.ClientConfig()
		if err != nil {
			return nil, err
		}
		c := credentials.NewTLS(tlscfg)
		creds = &c
	}
	// use a temporary skeleton client to bootstrap first connection
	conn, err := cfg.RetryDialer(&Client{cfg: *cfg, creds: creds})
	if err != nil {
		return nil, err
	}
	return &Client{
		KV:      pb.NewKVClient(conn),
		Lease:   pb.NewLeaseClient(conn),
		Watch:   pb.NewWatchClient(conn),
		Cluster: pb.NewClusterClient(conn),
		conn:    conn,
		cfg:     *cfg,
		creds:   creds,
	}, nil
}
開發者ID:obeattie,項目名稱:etcd,代碼行數:28,代碼來源:client.go

示例3: memberUpdateCommandFunc

// memberUpdateCommandFunc executes the "member update" command.
func memberUpdateCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) != 1 {
		ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided"))
	}

	id, err := strconv.ParseUint(args[0], 16, 64)
	if err != nil {
		ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err))
	}

	if len(memberPeerURLs) == 0 {
		ExitWithError(ExitBadArgs, fmt.Errorf("member peer urls not provided."))
	}

	urls := strings.Split(memberPeerURLs, ",")

	endpoint, err := cmd.Flags().GetString("endpoint")
	if err != nil {
		ExitWithError(ExitError, err)
	}
	conn, err := grpc.Dial(endpoint)
	if err != nil {
		ExitWithError(ExitBadConnection, err)
	}
	mc := pb.NewClusterClient(conn)

	resp, err := mc.MemberUpdate(context.TODO(), &pb.MemberUpdateRequest{ID: uint64(id), PeerURLs: urls})
	if err != nil {
		ExitWithError(ExitError, err)
	}

	fmt.Printf("Member %16x updated in cluster %16x\n", id, resp.Header.ClusterId)
}
開發者ID:rtewalt,項目名稱:etcd,代碼行數:34,代碼來源:member_command.go

示例4: memberRemoveCommandFunc

// memberRemoveCommandFunc executes the "member remove" command.
func memberRemoveCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) != 1 {
		ExitWithError(ExitBadArgs, fmt.Errorf("member ID is not provided"))
	}

	id, err := strconv.ParseUint(args[0], 16, 64)
	if err != nil {
		ExitWithError(ExitBadArgs, fmt.Errorf("bad member ID arg (%v), expecting ID in Hex", err))
	}

	endpoint, err := cmd.Flags().GetString("endpoint")
	if err != nil {
		ExitWithError(ExitError, err)
	}
	conn, err := grpc.Dial(endpoint)
	if err != nil {
		ExitWithError(ExitBadConnection, err)
	}
	mc := pb.NewClusterClient(conn)

	resp, err := mc.MemberRemove(context.TODO(), &pb.MemberRemoveRequest{ID: uint64(id)})
	if err != nil {
		ExitWithError(ExitError, err)
	}

	fmt.Printf("Member %16x removed from cluster %16x\n", id, resp.Header.ClusterId)
}
開發者ID:rtewalt,項目名稱:etcd,代碼行數:28,代碼來源:member_command.go

示例5: memberAddCommandFunc

// memberAddCommandFunc executes the "member add" command.
func memberAddCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) != 1 {
		ExitWithError(ExitBadArgs, fmt.Errorf("member name not provided."))
	}

	if len(memberPeerURLs) == 0 {
		ExitWithError(ExitBadArgs, fmt.Errorf("member peer urls not provided."))
	}

	urls := strings.Split(memberPeerURLs, ",")

	endpoint, err := cmd.Flags().GetString("endpoint")
	if err != nil {
		ExitWithError(ExitError, err)
	}
	conn, err := grpc.Dial(endpoint)
	if err != nil {
		ExitWithError(ExitBadConnection, err)
	}
	mc := pb.NewClusterClient(conn)

	resp, err := mc.MemberAdd(context.TODO(), &pb.MemberAddRequest{PeerURLs: urls})
	if err != nil {
		ExitWithError(ExitError, err)
	}

	fmt.Printf("Member %16x added to cluster %16x\n", args[0], resp.Member.ID, resp.Header.ClusterId)
}
開發者ID:rtewalt,項目名稱:etcd,代碼行數:29,代碼來源:member_command.go

示例6: toGRPC

func toGRPC(c *clientv3.Client) grpcAPI {
	return grpcAPI{
		pb.NewClusterClient(c.ActiveConnection()),
		pb.NewKVClient(c.ActiveConnection()),
		pb.NewLeaseClient(c.ActiveConnection()),
		pb.NewWatchClient(c.ActiveConnection()),
	}
}
開發者ID:rhuss,項目名稱:gofabric8,代碼行數:8,代碼來源:cluster.go

示例7: NewCluster

func NewCluster(c *Client) Cluster {
	conn := c.ActiveConnection()

	return &cluster{
		c: c,

		conn:   conn,
		remote: pb.NewClusterClient(conn),
	}
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:10,代碼來源:cluster.go

示例8: toGRPC

func toGRPC(c *clientv3.Client) grpcAPI {
	if v, ok := proxies[c]; ok {
		return v
	}
	return grpcAPI{
		pb.NewClusterClient(c.ActiveConnection()),
		grpcproxy.KvServerToKvClient(grpcproxy.NewKvProxy(c)),
		pb.NewLeaseClient(c.ActiveConnection()),
		grpcproxy.WatchServerToWatchClient(grpcproxy.NewWatchProxy(c)),
		pb.NewMaintenanceClient(c.ActiveConnection()),
	}
}
開發者ID:mgurevin,項目名稱:etcd,代碼行數:12,代碼來源:cluster_proxy.go

示例9: switchRemote

func (c *cluster) switchRemote(prevErr error) error {
	newConn, err := c.c.retryConnection(c.conn, prevErr)
	if err != nil {
		return err
	}

	c.mu.Lock()
	defer c.mu.Unlock()

	c.conn = newConn
	c.remote = pb.NewClusterClient(c.conn)
	return nil
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:13,代碼來源:cluster.go

示例10: newClient

func newClient(conn *grpc.ClientConn, cfg *Config) *Client {
	if cfg == nil {
		cfg = &Config{RetryDialer: dialEndpointList}
	}
	return &Client{
		KV:      pb.NewKVClient(conn),
		Lease:   pb.NewLeaseClient(conn),
		Watch:   pb.NewWatchClient(conn),
		Cluster: pb.NewClusterClient(conn),
		conn:    conn,
		cfg:     *cfg,
	}
}
開發者ID:s016374,項目名稱:etcd,代碼行數:13,代碼來源:client.go

示例11: toGRPC

func toGRPC(c *clientv3.Client) grpcAPI {
	pmu.Lock()
	defer pmu.Unlock()

	if v, ok := proxies[c]; ok {
		return v
	}
	api := grpcAPI{
		pb.NewClusterClient(c.ActiveConnection()),
		grpcproxy.KvServerToKvClient(grpcproxy.NewKvProxy(c)),
		pb.NewLeaseClient(c.ActiveConnection()),
		grpcproxy.WatchServerToWatchClient(grpcproxy.NewWatchProxy(c)),
		pb.NewMaintenanceClient(c.ActiveConnection()),
	}
	proxies[c] = api
	return api
}
開發者ID:nhr,項目名稱:origin,代碼行數:17,代碼來源:cluster_proxy.go

示例12: newClient

func newClient(conn *grpc.ClientConn, cfg *Config) (*Client, error) {
	if cfg == nil {
		cfg = &Config{RetryDialer: dialEndpointList}
	}
	var creds *credentials.TransportAuthenticator
	if cfg.TLS != nil {
		tlscfg, err := cfg.TLS.ClientConfig()
		if err != nil {
			return nil, err
		}
		c := credentials.NewTLS(tlscfg)
		creds = &c
	}
	return &Client{
		KV:      pb.NewKVClient(conn),
		Lease:   pb.NewLeaseClient(conn),
		Watch:   pb.NewWatchClient(conn),
		Cluster: pb.NewClusterClient(conn),
		conn:    conn,
		cfg:     *cfg,
		creds:   creds,
	}, nil
}
開發者ID:lth2015,項目名稱:esbeat,代碼行數:23,代碼來源:client.go

示例13: RetryClusterClient

// RetryClusterClient implements a ClusterClient that uses the client's FailFast retry policy.
func RetryClusterClient(c *Client) pb.ClusterClient {
	return &retryClusterClient{pb.NewClusterClient(c.conn), c.retryWrapper}
}
開發者ID:nhr,項目名稱:origin,代碼行數:4,代碼來源:retry.go

示例14: NewCluster

func NewCluster(c *Client) Cluster {
	return &cluster{remote: pb.NewClusterClient(c.conn)}
}
開發者ID:AdoHe,項目名稱:kubernetes,代碼行數:3,代碼來源:cluster.go

示例15: MemberList

func (cp *clusterProxy) MemberList(ctx context.Context, r *pb.MemberListRequest) (*pb.MemberListResponse, error) {
	conn := cp.client.ActiveConnection()
	return pb.NewClusterClient(conn).MemberList(ctx, r)
}
開發者ID:nhr,項目名稱:origin,代碼行數:4,代碼來源:cluster.go


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