armeria-0.41.0
New features
-
#455 #465 Add
RequestContext.onChild()which adds a callback that is invoked when a child context replaces the current context-
This is useful especially when you want to inherit an attribute of the current context to its children:
AttributeKey<UserInfo> CURRENT_USER = ...; RequestContext ctx = ...; ctx.onChild((curCtx, newCtx) -> { newCtx.attr(CURRENT_USER).set(curCtx.attr(CURRENT_USER).get()); });
-
-
#460 Add
DynamicEndpointGroupwhich notifies its listeners when its list ofEndpoints changesHealthCheckedEndpointGroupandZooKeeperEndpointGroupextendsDynamicEndpointGroup.
-
#471 Provide more simpler ways to write a decorating client/server
-
Add
DecoratingClientFunctionwhich is similar toDecoratingServiceFunction:ServerBuilder sb = new ServerBuilder(); sb.serviceUnder("/my_service", new MyService().decorate((delegate, ctx, req) -> { // Intercept an incoming request here. return delegate.serve(ctx, req); }); ClientBuilder cb = new ClientBuilder(...); cb.decorator(HttpRequest.class, HttpResponse.class, (delegate, ctx, req) -> { // Intercept an outgoing request here. return delegate.execute(ctx, req); });
-
Add
SimpleDecoratingServiceandSimpleDecoratingClient, which is similar toDecoratingServiceandDecoratingClientbut with fewer number of type parameters:public class MyDecoratingService extends SimpleDecoratingService<RpcRequest, RpcResponse> { ... } public class MyDecoratingClient extends SimpleDecoratingClient<RpcRequest, RpcResponse> { ... }
-
Improvements
- (Potentially breaking) #457 Cancel context-aware callbacks automatically if the context has been timed out already