I would like to be able to read gRPC metadata when making a unary call with the gRPC client. Currently this is already possible with StreamCalls' which is also properly documented, but I can't figure it out with Unary Call's
Consider the following code:
Simplified Provider:
{
provide: 'SERVICE_GRPC',
useFactory: () => {
return ClientProxyFactory.create({
transport: Transport.GRPC,
options: {
package: 'myPackage',
protoPath: 'my.proto
url: '127.0.0.1',
},
});
}
},
Simplified Class
interface SomeService {
someGrpcMethod: (argument: Request) => Observable<Response>;
}
class SomeClass {
constructor(@Inject('SERVICE_GRPC') private readonly _client: ClientGrpc) {}
onModuleInit(): void {
this._someService = this._client.getService<SomeService>('SomeService');
}
someMethod(): void {
const observer = this._someService.someGrpcMethod({param1:true})
// Need the metadata send by server here
observer.subscribe(...);
}
}
Does anyone know how to do this?