Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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. 

Description

Summary

The Ignite Service Grid must support the following capabilities:

  1. Ability to pass custom context from caller to service (similar to HTTP request headers).
  2. Ability to define custom interceptors for service calls.

Suggested design

New public API entities

  • ServiceCallContext -  immutable map of custom parameters to be implicitly passed to the service.
  • ServiceCallInterceptor  - intercepts service method calls.
  • ServiceInterceptorContext -  extended mutable version of caller context (interceptor obtains method call parameters from it and can use it to update the caller context).
  • ServiceInterceptException - unchecked exception that is used to highlight the exception that occurred during method interception (not execution).

Java API

Code Block
languagejava
themeConfluence
titleServiceCallInterceptor
linenumberstrue
public interface ServiceCallInterceptor extends Serializable {
    public default void onInvoke(ServiceInterceptorContext ctx) throws ServiceInterceptException {
        // No-op.
    }

    public default void onComplete(@Nullable Object res, ServiceInterceptorContext ctx) throws ServiceInterceptException {
        // No-op.
    }

    public default void onError(Throwable err, ServiceInterceptorContext ctx) {
        // No-op.
    }
}

...