DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
| ID | IEP-79 |
| Author | Pavel Pereslegin |
| Sponsor | |
| Created | 13 Oct 2021 |
| Status | DRAFT |
When implementing microservices, users are often face with the task of separating the business logic from the common "middleware" logic.
An example of a typical “middleware” task is auditing calls to business service methods (the system must understand which user called which methods and with what result).
Modern frameworks such as gRPC[1] provide flexible API for implementing request interceptors, with which you can solve almost any middleware task.
Apache Ignite does not provide any mechanisms for solving such problems in general. The user needs to implement it himself, which often results in a lot of boilerplate code.
The Ignite Service Grid must support the following capabilities:
ServiceCallContext - immutable user parameter map that can be implicitly passed to the service (and interceptor) on every method call.
ServiceCallInterceptor - intercepts service method calls.
One service can have several interceptors. They are defined using the service configuration and deployed with the service.
To add/remove interceptor service should be redeployed.
Interceptor is located and executed where the service is implemented (for Java service - on Java side, for .NET-service on .NET side). Its execution should not cause additional serialization).
The user can specify multiple interceptors. Each interceptor invokes the next interceptor in the chain using a delegated call, the last interceptor will call the service method.
So the interceptor specified first in the configuration will process the result of the service method execution last.
Interceptor must support the injection of generic resources.
Interceptor does not apply to service lifecycle methods - init, execute and cancel,
The user can create context (map with custom parameters) and bind it to the service proxy. After that, each call to the proxy method will also implicitly pass context parameters to the service.
Service method can read current context parameters using ServiceContext#currentCallContext method. It is only accessible from the current thread during the execution of a service method.
If one service calls another, then by default the current call context will not be bound to the created proxy - the user must explicitly bind it. But Java service has a special ServiceResource annotation to inject another service proxy into the current service. If the user wants to redirect the current call context to this (injected) proxy, he can set the forwardCallerContext option of this annotation.
Exception thrown by the interceptor will be wrapped into unchecked IgniteException and passed to the initiator.
The interceptor gives the user full control over the invocation of the service methods, so in case of implementation errors, the user may get unexpected behavior of the service.
[1] https://pkg.go.dev/github.com/grpc-ecosystem/go-grpc-middleware