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

GRPC client increase max message size #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package plugin
import (
"crypto/tls"
"fmt"
"math"
"net"
"time"

Expand All @@ -14,6 +13,11 @@ import (
"google.golang.org/grpc/health/grpc_health_v1"
)

// maxInt is defined here to allow 64-bit architectures to set message size
// limits greater than 2^31-1. This is used rather than [math.MaxInt] to support
// go versions < 1.17.
const maxInt = int(^uint(0) >> 1)

func dialGRPCConn(tls *tls.Config, dialer func(string, time.Duration) (net.Conn, error), dialOpts ...grpc.DialOption) (*grpc.ClientConn, error) {
// Build dialing options.
opts := make([]grpc.DialOption, 0)
Expand All @@ -34,8 +38,8 @@ func dialGRPCConn(tls *tls.Config, dialer func(string, time.Duration) (net.Conn,
}

opts = append(opts,
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt32)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(math.MaxInt32)))
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxInt)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(maxInt)))

// Add our custom options if we have any
opts = append(opts, dialOpts...)
Expand Down