swarmctl
实质上是通过controlClient
向swarm cluster
发命令。controlClient
定义在api/control.pb.go
:
// Client API for Control service
type ControlClient interface {
GetNode(ctx context.Context, in *GetNodeRequest, opts ...grpc.CallOption) (*GetNodeResponse, error)
ListNodes(ctx context.Context, in *ListNodesRequest, opts ...grpc.CallOption) (*ListNodesResponse, error)
......
}
type controlClient struct {
cc *grpc.ClientConn
}
func NewControlClient(cc *grpc.ClientConn) ControlClient {
return &controlClient{cc}
}
func (c *controlClient) GetNode(ctx context.Context, in *GetNodeRequest, opts ...grpc.CallOption) (*GetNodeResponse, error) {
out := new(GetNodeResponse)
err := grpc.Invoke(ctx, "/docker.swarmkit.v1.Control/GetNode", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
......