Skip to content

Commit

Permalink
Use maximum value for gRPC message size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsomesan committed Sep 13, 2021
1 parent a741d49 commit 6f9312a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tfprotov5/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tf5server

import (
"context"
"math"
"sync"

"github.com/hashicorp/go-hclog"
Expand All @@ -10,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/fromproto"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/toproto"
"google.golang.org/grpc"
)

// ServeOpt is an interface for defining options that can be passed to the
Expand Down Expand Up @@ -55,6 +57,12 @@ func WithGoPluginLogger(logger hclog.Logger) ServeOpt {
})
}

func MaxMsgGRPCServer(opts []grpc.ServerOption) *grpc.Server {
opts = append(opts, grpc.MaxSendMsgSize(math.MaxInt32))
opts = append(opts, grpc.MaxRecvMsgSize(math.MaxInt32))
return grpc.NewServer(opts...)
}

// Serve starts a tfprotov5.ProviderServer serving, ready for Terraform to
// connect to it. The name passed in should be the fully qualified name that
// users will enter in the source field of the required_providers block, like
Expand Down Expand Up @@ -83,7 +91,7 @@ func Serve(name string, serverFactory func() tfprotov5.ProviderServer, opts ...S
GRPCProvider: serverFactory,
},
},
GRPCServer: plugin.DefaultGRPCServer,
GRPCServer: MaxMsgGRPCServer,
}
if conf.logger != nil {
serveConfig.Logger = conf.logger
Expand Down

0 comments on commit 6f9312a

Please sign in to comment.