Skip to content
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
8 changes: 7 additions & 1 deletion state/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ func NewConnectedClient(ctx context.Context, backendOpts *plugin.BackendOptions)
// The state client is guaranteed to be non-nil (it defaults to the NoOpClient).
// You must call Close() on the returned Client object.
func NewConnectedClientWithOptions(ctx context.Context, backendOpts *plugin.BackendOptions, connOpts ConnectionOptions, clOpts ClientOptions) (Client, error) {
if backendOpts == nil {
// backend_options missing or configured but empty
if backendOpts == nil || (backendOpts.Connection == "" && backendOpts.TableName == "") {
return &NoOpClient{}, nil
}

// backend_options configured incorrectly, e.g. missing connection or table_name
if backendOpts.Connection == "" || backendOpts.TableName == "" {
return nil, fmt.Errorf("backend_options must contain both connection and table_name: %v", backendOpts)
}

backendConn, err := grpc.NewClient(backendOpts.Connection,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(
Expand Down
Loading