Skip to content

Commit

Permalink
message size
Browse files Browse the repository at this point in the history
Signed-off-by: Yashash H L <yashash_hl@intuit.com>
  • Loading branch information
yhl25 committed Jan 25, 2023
1 parent 62aac74 commit b628020
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pkg/function/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type client struct {
func New(inputOptions ...Option) (*client, error) {

var opts = &options{
sockAddr: function.Addr,
sockAddr: function.Addr,
maxMessageSize: function.DefaultMaxMessageSize,
}

for _, inputOption := range inputOptions {
Expand All @@ -30,7 +31,10 @@ func New(inputOptions ...Option) (*client, error) {

c := new(client)
sockAddr := fmt.Sprintf("%s:%s", function.Protocol, opts.sockAddr)
conn, err := grpc.Dial(sockAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))

conn, err := grpc.Dial(sockAddr, grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(opts.maxMessageSize), grpc.MaxCallSendMsgSize(opts.maxMessageSize)))

if err != nil {
return nil, fmt.Errorf("failed to execute grpc.Dial(%q): %w", sockAddr, err)
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/function/client/options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package client

type options struct {
sockAddr string
sockAddr string
maxMessageSize int
}

// Option is the interface to apply options.
Expand All @@ -13,3 +14,10 @@ func WithSockAddr(addr string) Option {
opts.sockAddr = addr
}
}

// WithMaxMessageSize sets the server max receive message size and the server max send message size to the given size.
func WithMaxMessageSize(size int) Option {
return func(opts *options) {
opts.maxMessageSize = size
}
}

0 comments on commit b628020

Please sign in to comment.