interceptUnary<Q, R> method
ResponseFuture<R>
interceptUnary<Q, R>(
- ClientMethod<
Q, R> method, - Q request,
- CallOptions options,
- ClientUnaryInvoker<
Q, R> invoker,
Implementation
@override
ResponseFuture<R> interceptUnary<Q, R>(ClientMethod<Q, R> method, Q request, CallOptions options, ClientUnaryInvoker<Q, R> invoker) {
var logger = Logger(
filter: useInProd ? ProductionFilter() : null,
printer: PrettyPrinter(methodCount: 0, errorMethodCount: 8, lineLength: 0, colors: false, printEmojis: false, printTime: false),
output: ConsoleOutput(false),
);
var loggerResp = Logger(
filter: useInProd ? ProductionFilter() : null,
printer: PrettyPrinter(methodCount: 0, errorMethodCount: 8, lineLength: 0, colors: false, printEmojis: false, printTime: false),
output: ConsoleOutput(true),
);
String key = getRandomString(5);
if (isActive) {
logger.d(
'[$key] \n'
'Grpc request. \n'
'method: ${method.path}, \n'
'request: $request',
);
}
final response = invoker(method, request, options)
..catchError((e) async {
debugPrint('handle errors here $e');
if (e is GrpcError) {
debugGrpc(e);
if (isError != null) isError!(e);
}
});
if (isActive) {
response.then((p0) => {
loggerResp.d(
'[$key] \n'
'Grpc response. \n'
'method: ${method.path}, \n'
'response: $p0',
)
});
}
return response;
}