MCPcopy
hub / github.com/grafana/dskit / ClusterUnaryClientInterceptor

Function ClusterUnaryClientInterceptor

middleware/grpc_cluster.go:35–41  ·  view source on GitHub ↗

ClusterUnaryClientInterceptor propagates the given cluster label to gRPC metadata, before calling the next invoker. If an empty cluster label, or a nil InvalidClusterValidationReporter are provided, ClusterUnaryClientInterceptor panics. In case of an error related to the cluster label validation, In

(cluster string, invalidClusterValidationReporter InvalidClusterValidationReporter)

Source from the content-addressed store, hash-verified

33// In case of an error related to the cluster label validation, InvalidClusterValidationReporter is called, and the error
34// is returned.
35func ClusterUnaryClientInterceptor(cluster string, invalidClusterValidationReporter InvalidClusterValidationReporter) grpc.UnaryClientInterceptor {
36 validateClusterClientInterceptorInputParameters(cluster, invalidClusterValidationReporter)
37 return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
38 ctx = clusterutil.PutClusterIntoOutgoingContext(ctx, cluster)
39 return handleClusterValidationError(invoker(ctx, method, req, reply, cc, opts...), method, invalidClusterValidationReporter)
40 }
41}
42
43func validateClusterClientInterceptorInputParameters(cluster string, invalidClusterValidationReporter InvalidClusterValidationReporter) {
44 if cluster == "" {

Callers 2

DialOptionMethod · 0.92

Tested by 1