Skip to content

Commit

Permalink
Make a centralized list for call options
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Feb 6, 2018
1 parent 547f8ca commit 85ef4cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 16 additions & 0 deletions logical/plugin/grpc_backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package plugin

import (
"math"

"google.golang.org/grpc"
)

var defaultGRPCCallOpts []grpc.CallOption

func init() {
defaultGRPCCallOpts = []grpc.CallOption{
grpc.MaxCallSendMsgSize(math.MaxInt32),
grpc.MaxCallRecvMsgSize(math.MaxInt32),
}
}
5 changes: 2 additions & 3 deletions logical/plugin/grpc_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package plugin
import (
"context"
"errors"
"math"

"google.golang.org/grpc"

Expand Down Expand Up @@ -54,7 +53,7 @@ func (b *backendGRPCPluginClient) HandleRequest(ctx context.Context, req *logica

reply, err := b.client.HandleRequest(ctx, &pb.HandleRequestArgs{
Request: protoReq,
}, grpc.MaxCallSendMsgSize(math.MaxInt32), grpc.MaxCallRecvMsgSize(math.MaxInt32))
}, defaultGRPCCallOpts...)
if err != nil {
if b.doneCtx.Err() != nil {
return nil, ErrPluginShutdown
Expand Down Expand Up @@ -116,7 +115,7 @@ func (b *backendGRPCPluginClient) HandleExistenceCheck(ctx context.Context, req
defer cancel()
reply, err := b.client.HandleExistenceCheck(ctx, &pb.HandleExistenceCheckArgs{
Request: protoReq,
}, grpc.MaxCallSendMsgSize(math.MaxInt32), grpc.MaxCallRecvMsgSize(math.MaxInt32))
}, defaultGRPCCallOpts...)
if err != nil {
if b.doneCtx.Err() != nil {
return false, false, ErrPluginShutdown
Expand Down
7 changes: 3 additions & 4 deletions logical/plugin/grpc_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package plugin
import (
"context"
"errors"
"math"

"google.golang.org/grpc"

Expand All @@ -26,7 +25,7 @@ type GRPCStorageClient struct {
func (s *GRPCStorageClient) List(ctx context.Context, prefix string) ([]string, error) {
reply, err := s.client.List(ctx, &pb.StorageListArgs{
Prefix: prefix,
}, grpc.MaxCallSendMsgSize(math.MaxInt32), grpc.MaxCallRecvMsgSize(math.MaxInt32))
}, defaultGRPCCallOpts...)
if err != nil {
return reply.Keys, err
}
Expand All @@ -39,7 +38,7 @@ func (s *GRPCStorageClient) List(ctx context.Context, prefix string) ([]string,
func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.StorageEntry, error) {
reply, err := s.client.Get(ctx, &pb.StorageGetArgs{
Key: key,
}, grpc.MaxCallSendMsgSize(math.MaxInt32), grpc.MaxCallRecvMsgSize(math.MaxInt32))
}, defaultGRPCCallOpts...)
if err != nil {
return nil, err
}
Expand All @@ -52,7 +51,7 @@ func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.Stora
func (s *GRPCStorageClient) Put(ctx context.Context, entry *logical.StorageEntry) error {
reply, err := s.client.Put(ctx, &pb.StoragePutArgs{
Entry: pb.LogicalStorageEntryToProtoStorageEntry(entry),
}, grpc.MaxCallSendMsgSize(math.MaxInt32), grpc.MaxCallRecvMsgSize(math.MaxInt32))
}, defaultGRPCCallOpts...)
if err != nil {
return err
}
Expand Down

0 comments on commit 85ef4cb

Please sign in to comment.