Package com.linecorp.armeria.common.grpc
Class GrpcCallOptions
java.lang.Object
com.linecorp.armeria.common.grpc.GrpcCallOptions
Retrieves
CallOptions
from a given RequestContext
. This might be useful while providing
common middleware that needs to act on options configured at the gRPC client's call site.
Here is an example of how custom call options might be propagated between a gRPC stub and a decorator.
MyGrpcStub client = GrpcClients
.builder(grpcServerUri)
.decorator((delegate, ctx, req) -> {
CallOptions options = GrpcCallOptions.get(ctx);
MyOption myOption = options.getOption(myOptionKey);
// act on myOption if needed
return delegate.execute(ctx, req);
})
.build(MyGrpcStub.class)
client
.withOption(myOptionKey, myOptionValue)
.echo(...)
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable io.grpc.CallOptions
get
(RequestContext ctx) ReturnsCallOptions
which was set to the specifiedRequestContext
usingset(RequestContext, CallOptions)
.static void
set
(RequestContext ctx, io.grpc.CallOptions options) Sets the specifiedCallOptions
to theRequestContext
.
-
Method Details
-
get
ReturnsCallOptions
which was set to the specifiedRequestContext
usingset(RequestContext, CallOptions)
. -
set
Sets the specifiedCallOptions
to theRequestContext
.
-