Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for custom grpc dial options in Go SDK #1043

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sdk/go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/x509"
"fmt"

"github.com/feast-dev/feast/sdk/go/protos/feast/serving"
"github.com/opentracing/opentracing-go"
"go.opencensus.io/plugin/ocgrpc"
Expand Down Expand Up @@ -43,16 +44,25 @@ func NewGrpcClient(host string, port int) (*GrpcClient, error) {
})
}

// NewAuthGrpcClient constructs a secure client that uses security features (ie authentication).
// NewSecureGrpcClient constructs a secure client that uses security features (ie authentication).
// host - hostname of the serving host/instance to connect to.
// port - post of the host to service host/instancf to connect to.
// securityConfig - security config configures client security.
func NewSecureGrpcClient(host string, port int, security SecurityConfig) (*GrpcClient, error) {
return NewSecureGrpcClientWithDialOptions(host, port, security)
}

// NewSecureGrpcClientWithDialOptions constructs a secure client that uses security features (ie authentication) along with custom grpc dial options.
// host - hostname of the serving host/instance to connect to.
// port - post of the host to service host/instancf to connect to.
// securityConfig - security config configures client security.
// opts - grpc.DialOptions which should be used with this connection
func NewSecureGrpcClientWithDialOptions(host string, port int, security SecurityConfig, opts ...grpc.DialOption) (*GrpcClient, error) {
feastCli := &GrpcClient{}
adr := fmt.Sprintf("%s:%d", host, port)

// Compile grpc dial options from security config.
options := []grpc.DialOption{grpc.WithStatsHandler(&ocgrpc.ClientHandler{})}
options := append(opts, grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
// Configure client TLS.
if !security.EnableTLS {
options = append(options, grpc.WithInsecure())
Expand Down