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)
| 33 | // In case of an error related to the cluster label validation, InvalidClusterValidationReporter is called, and the error |
| 34 | // is returned. |
| 35 | func 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 | |
| 43 | func validateClusterClientInterceptorInputParameters(cluster string, invalidClusterValidationReporter InvalidClusterValidationReporter) { |
| 44 | if cluster == "" { |