-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the feature
Going forward, we should probably have the ability to intercept or pipe through messages on both client and server. This would have various uses for authorization on both server and client, and it would also allow users to easily extend the functionality with their own code. I think we should allow for potential chaining, the ability to set context, etc. We need to put the interception probably between the message being properly decoded, as there are many variants/forms the message can come through.
Potentional example:
public interface MessageInterceptor {
String getName();
int getPriority();
Future<MessageContext> process(MessageContext context) throws InterceptorException;
}
public class MessageContext {
private GrpcMessage message;
private Map<String, Object> attributes;
private UserContext user;
private Direction direction; // INBOUND/OUTBOUND
}Examples:
public class AuthInterceptor implements MessageInterceptor {
public Future<MessageContext> process(MessageContext ctx) {
if (!hasPermission(ctx.getUser(), ctx.getMessage())) {
throw new UnauthorizedException();
}
return Future.succededFuture(ctx);
}
}
public class TransformInterceptor implements MessageInterceptor {
public Future<MessageContext> process(MessageContext ctx) {
ctx.setMessage(transform(ctx.getMessage()));
return Future.succededFuture(ctx);
}
}Contribution
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request