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

Handle credentials in Config.Connect() #36

Merged
merged 1 commit into from
Nov 11, 2024
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
12 changes: 12 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,23 @@ type Config struct {

// Additional headers to include in requests to the service.
Headers map[string]string `json:"headers"`

// Deprecated: no longer used. Timeouts are controlled on a per-call basis
// by the provided context.
TimeoutInSeconds int `json:"timeout_in_seconds"`
}

// Connects to the service specified in Config, possibly with additional
// connection options.
func (cfg *Config) Connect(opts ...ConnectionOption) (*grpc.ClientConn, error) {
if cfg.APIKey != "" {
opts = append(opts, WithAPIKeyAuth(cfg.APIKey))
}

if cfg.Token != "" {
opts = append(opts, WithTokenAuth(cfg.Token))
}

connOpts := &ConnectionOptions{Config: *cfg}
if err := connOpts.Apply(opts...); err != nil {
return nil, err
Expand Down
Loading