func New()

in testutils/kmspluginclient/kmspluginclient.go [41:68]


func New(endpoint string) (*Client, error) {
	addr, err := parseEndpoint(endpoint)
	if err != nil {
		return nil, err
	}

	connection, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.FailFast(false)), grpc.WithDialer(
		func(string, time.Duration) (net.Conn, error) {
			// Ignoring addr and timeout arguments:
			// addr - comes from the closure
			// timeout - is ignored since we are connecting in a non-blocking configuration
			c, err := net.DialTimeout("unix", addr, 0)
			if err != nil {
				return nil, fmt.Errorf("failed to create connection to unix socket: %s, error: %v", addr, err)
			}
			return c, nil
		}))

	if err != nil {
		return nil, fmt.Errorf("failed to create connection to %s, error: %v", addr, err)
	}

	kmsClient := plugin.NewKeyManagementServiceClient(connection)
	return &Client{
		KeyManagementServiceClient: kmsClient,
		connection:                 connection,
	}, nil
}