[ 
https://issues.apache.org/jira/browse/IGNITE-15572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel Pereslegin reassigned IGNITE-15572:
-----------------------------------------

    Assignee: Pavel Pereslegin

> Ability to set custom execution context for Ignite service.
> -----------------------------------------------------------
>
>                 Key: IGNITE-15572
>                 URL: https://issues.apache.org/jira/browse/IGNITE-15572
>             Project: Ignite
>          Issue Type: New Feature
>            Reporter: Pavel Pereslegin
>            Assignee: Pavel Pereslegin
>            Priority: Major
>
> In traditional microservices, we have the ability to set a custom execution 
> context.
> For example, a REST service can read the session ID from a request. We can 
> say that each client request, in this case, has a set of explicit and 
> implicit parameters.  One of the implicit parameters is a session identifier 
> that can be passed to the service using request headers.
> It would be nice to have a similar feature in Ignite services.
> The basic idea behind the implementation:
> 1. Allow the user to bind the "execution context" to the client proxy object.
> 2. Pass an additional implicit parameter each time the user service method is 
> called.
> Sample code for specifying "headers".
> {code:java}
> // Creating "request headers".
> Map<String, Object> headers = Collections.singletonMap("user.id", 1);
> // Binding "request headers" to proxy invocation handler.
> IMyService svcProxy = ignite.services().serviceProxy("service1", 
> IMyService.class, false, headers);
> // Service method invocation using this proxy.
> handle(svcProxy.multiply(2, 2));
> handle(svcProxy.multiply(3, 3));
> handle(svcProxy.multiply(4, 4));
> ...
> {code}
> Sample code for reading "headers".
> {code:java}
> class MyServiceImpl implements IMyService {
>     @LoggerResource
>     private IgniteLogger log;
>     private ServiceContext ctx;
>     @Override public void init(ServiceContext ctx) {
>         this.ctx = ctx;
>     }
>     @Override public int multiply(int a, int b) {
>         log.info(String.format("user=%d, oper=%s, a=%d, b=%d", 
> ctx.getHeaders().get("user.id"), "multiply", a, b));
>         return a * b;
>     }
>     ...
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to