-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
receive: use gRPC for forwarding messages #1970
Merged
+864
−241
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package extgrpc | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/go-kit/kit/log" | ||
"github.com/go-kit/kit/log/level" | ||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" | ||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" | ||
opentracing "github.com/opentracing/opentracing-go" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/thanos-io/thanos/pkg/tls" | ||
"github.com/thanos-io/thanos/pkg/tracing" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials" | ||
) | ||
|
||
// StoreClientGRPCOpts creates gRPC dial options for connecting to a store client. | ||
func StoreClientGRPCOpts(logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, secure bool, cert, key, caCert, serverName string) ([]grpc.DialOption, error) { | ||
grpcMets := grpc_prometheus.NewClientMetrics() | ||
grpcMets.EnableClientHandlingTimeHistogram( | ||
grpc_prometheus.WithHistogramBuckets([]float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120}), | ||
) | ||
dialOpts := []grpc.DialOption{ | ||
// We want to make sure that we can receive huge gRPC messages from storeAPI. | ||
// On TCP level we can be fine, but the gRPC overhead for huge messages could be significant. | ||
// Current limit is ~2GB. | ||
// TODO(bplotka): Split sent chunks on store node per max 4MB chunks if needed. | ||
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt32)), | ||
grpc.WithUnaryInterceptor( | ||
grpc_middleware.ChainUnaryClient( | ||
grpcMets.UnaryClientInterceptor(), | ||
tracing.UnaryClientInterceptor(tracer), | ||
), | ||
), | ||
grpc.WithStreamInterceptor( | ||
grpc_middleware.ChainStreamClient( | ||
grpcMets.StreamClientInterceptor(), | ||
tracing.StreamClientInterceptor(tracer), | ||
), | ||
), | ||
} | ||
|
||
if reg != nil { | ||
reg.MustRegister(grpcMets) | ||
} | ||
|
||
if !secure { | ||
return append(dialOpts, grpc.WithInsecure()), nil | ||
} | ||
|
||
level.Info(logger).Log("msg", "enabling client to server TLS") | ||
|
||
tlsCfg, err := tls.NewClientConfig(logger, cert, key, caCert, serverName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsCfg))), nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need an item here that indicates that people need to change their hashring files to be just addresses that the gRPC client is built from, instead of the full http endpoint.