예제 #1
0
//NewCmdCtrlClient returns a cmdctrl client for the given address
func NewCmdCtrlClient(address string) (*CmdCtrlClient, error) {
	var err error
	var opts []grpc.DialOption
	var creds credentials.TransportAuthenticator
	creds = credentials.NewTLS(&tls.Config{
		InsecureSkipVerify: true,
	})
	opts = append(opts, grpc.WithTransportCredentials(creds))
	s := CmdCtrlClient{}
	s.conn, err = grpc.Dial(address, opts...)
	if err != nil {
		return &CmdCtrlClient{}, fmt.Errorf("Failed to dial ring server for config: %v", err)
	}
	s.client = cc.NewCmdCtrlClient(s.conn)
	return &s, nil
}
예제 #2
0
// Connect sets up a grpc connection for the node.
// Note that this will overwrite an existing conn.
func (n *managedNode) Connect() error {
	n.Lock()
	defer n.Unlock()
	var opts []grpc.DialOption
	var creds credentials.TransportAuthenticator
	var err error
	creds = credentials.NewTLS(&tls.Config{
		InsecureSkipVerify: true,
	})
	opts = append(opts, grpc.WithTransportCredentials(creds))
	n.conn, err = grpc.Dial(n.address, opts...)
	if err != nil {
		return fmt.Errorf("Failed to dial ring server for config: %v", err)
	}
	n.client = cc.NewCmdCtrlClient(n.conn)
	return nil
}
예제 #3
0
func NewManagedNode(o *ManagedNodeOpts) (ManagedNode, error) {
	var err error
	node := &managedNode{}
	if o.Address == "" {
		return &managedNode{}, fmt.Errorf("Invalid Address supplied")
	}
	node.address = o.Address
	node.grpcOpts = o.GrpcOpts

	// TODO: push tls setup out of NewManagedNode
	var creds credentials.TransportAuthenticator
	creds = credentials.NewTLS(&tls.Config{
		InsecureSkipVerify: true,
	})
	node.grpcOpts = append(node.grpcOpts, grpc.WithTransportCredentials(creds))
	node.conn, err = grpc.Dial(node.address, node.grpcOpts...)
	if err != nil {
		return &managedNode{}, fmt.Errorf("Failed to dial cmdctrl server for node %s: %v", node.address, err)
	}
	node.client = cc.NewCmdCtrlClient(node.conn)
	node.active = false
	node.failcount = 0
	return node, nil
}