fix metadata client interceptors

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2022-03-11 12:40:09 +01:00
parent 97ced73270
commit 08a67bf162
Signed by: adphi
GPG Key ID: 46BE4062DB2397FF

View File

@ -37,18 +37,14 @@ func (i mdInterceptors) StreamServerInterceptor() grpc.StreamServerInterceptor {
func (i mdInterceptors) UnaryClientInterceptor() grpc.UnaryClientInterceptor { func (i mdInterceptors) UnaryClientInterceptor() grpc.UnaryClientInterceptor {
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
if err := grpc.SetHeader(ctx, metadata.Pairs(i.pairs...)); err != nil { ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(i.pairs...))
return err
}
return invoker(ctx, method, req, reply, cc, opts...) return invoker(ctx, method, req, reply, cc, opts...)
} }
} }
func (i mdInterceptors) StreamClientInterceptor() grpc.StreamClientInterceptor { func (i mdInterceptors) StreamClientInterceptor() grpc.StreamClientInterceptor {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
if err := grpc.SetHeader(ctx, metadata.Pairs(i.pairs...)); err != nil { ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(i.pairs...))
return nil, err
}
return streamer(ctx, desc, cc, method, opts...) return streamer(ctx, desc, cc, method, opts...)
} }
} }