Skip to content

Commit

Permalink
Merge pull request #11276 from thaJeztah/client_WithExtraDialOpts
Browse files Browse the repository at this point in the history
client: add WithExtraDialOpts option
  • Loading branch information
estesp authored Jan 21, 2025
2 parents 39b872d + a6dc990 commit 10bfd5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ func New(address string, opts ...Opt) (*Client, error) {
if len(copts.dialOptions) > 0 {
gopts = copts.dialOptions
}
gopts = append(gopts, copts.extraDialOpts...)

gopts = append(gopts, grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize),
grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)))
Expand Down
14 changes: 14 additions & 0 deletions client/client_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type clientOpts struct {
defaultPlatform platforms.MatchComparer
services *services
dialOptions []grpc.DialOption
extraDialOpts []grpc.DialOption
callOptions []grpc.CallOption
timeout time.Duration
}
Expand Down Expand Up @@ -76,6 +77,19 @@ func WithDialOpts(opts []grpc.DialOption) Opt {
}
}

// WithExtraDialOpts allows additional grpc.DialOptions to be set on the
// connection. Unlike [WithDialOpts], options set here are appended to,
// instead of overriding previous options, which allows setting options
// to extend containerd client's defaults.
//
// This option can be used multiple times to set additional dial options.
func WithExtraDialOpts(opts []grpc.DialOption) Opt {
return func(c *clientOpts) error {
c.extraDialOpts = append(c.extraDialOpts, opts...)
return nil
}
}

// WithCallOpts allows grpc.CallOptions to be set on the connection
func WithCallOpts(opts []grpc.CallOption) Opt {
return func(c *clientOpts) error {
Expand Down

0 comments on commit 10bfd5f

Please sign in to comment.