unary<I extends Object, O extends Object> method
Future<UnaryResponse<I, O> >
unary<I extends Object, O extends Object>(
- Spec<
I, O> spec, - I input, [
- CallOptions? options
inherited
Call a unary RPC - a method that takes a single input message, and responds with a single output message.
Implementation
@override
Future<UnaryResponse<I, O>> unary<I extends Object, O extends Object>(
Spec<I, O> spec,
I input, [
CallOptions? options,
]) async {
final signal = CancelableSignal(parent: options?.signal);
try {
final req = UnaryRequest(
spec,
_baseUrl + spec.procedure,
_protocol.requestHeaders(
spec,
_codec,
sendCompression,
acceptCompressions,
options,
),
input,
signal,
);
if (_interceptors.isEmpty) {
return await _protocol.unary(
req,
_codec,
_httpClient,
sendCompression,
acceptCompressions,
);
}
final first = _interceptors.apply<I, O>(
(req) async {
return await _protocol.unary(
req as UnaryRequest<I, O>,
_codec,
_httpClient,
sendCompression,
acceptCompressions,
);
},
);
return await first(req) as UnaryResponse<I, O>;
} finally {
// Cleanup
signal.cancel();
}
}