Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #30 from pablokbs/gprc-maxsize
Browse files Browse the repository at this point in the history
Adding MaxCallRecvMsgSize and MaxCallSendMsgSize to etcd3
  • Loading branch information
mhausenblas authored Dec 4, 2018
2 parents 11286f2 + 38c2a57 commit 365ab61
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/util/etcd3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"math"
)

// maxMsgSize use 200MB as the default message size limit.
// grpc library default is 4MB
const maxMsgSize = 1024 * 1024 * 200

// NewClient3 creates an etcd3 client, optionally using SSL/TLS if secure is true.
// The endpoint is an URL such as http://localhost:2379.
func NewClient3(endpoint string, secure bool) (*clientv3.Client, error) {
Expand Down Expand Up @@ -57,9 +61,11 @@ func newSecureEtcd3Client(endpoint string) (*clientv3.Client, error) {
dialOptions := createGRPCOptions()

cli, err := clientv3.New(clientv3.Config{
DialOptions: dialOptions,
Endpoints: []string{endpoint},
TLS: tlsConfig,
DialOptions: dialOptions,
Endpoints: []string{endpoint},
TLS: tlsConfig,
MaxCallSendMsgSize: maxMsgSize,
MaxCallRecvMsgSize: maxMsgSize,
})
if err != nil {
return nil, err
Expand All @@ -74,4 +80,4 @@ func createGRPCOptions() []grpc.DialOption {
dialOptions = append(dialOptions, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxUint32)))
dialOptions = append(dialOptions, grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(math.MaxUint32)))
return dialOptions
}
}

0 comments on commit 365ab61

Please sign in to comment.