Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make EventLoop available to RemoteInvoker.invoke() #122

Merged
merged 1 commit into from
Mar 7, 2016

Conversation

trustin
Copy link
Member

@trustin trustin commented Mar 7, 2016

Motivation:

EventLoop to perform the actual invocation is determined at the
HttpRemoteInvoker.invoke() method, which is the last moment right before
the invocation.

It means decorating RemoteInvokers does not have an access to the
EventLoop, nevertheless the EventLoop can be determined from the
beginning of the invocation.

A decorating RemoteInvoker with an access to an EventLoop could create
Future/Promise and schedule a task, which will be useful when building
an advanced decorator such as a circuit breaker.

Modifications:

  • Add EventLoop parameter to RemoteInvoker.invoke()
  • Determine the EventLoop to perform the invocation in
    ClientInvocationHandler instead of in HttpRemoteInvoker
    • Move HttpRemoteInvoker.eventLoop() to ClientInvocationHandler
  • Reorder the methods in HttpRemoteInvoker for readability

Result:

A decorating RemoteInvoker now has an access to the EventLoop which will
perform the actual invocation.

Motivation:

EventLoop to perform the actual invocation is determined at the
HttpRemoteInvoker.invoke() method, which is the last moment right before
the invocation.

It means decorating RemoteInvokers does not have an access to the
EventLoop, nevertheless the EventLoop can be determined from the
beginning of the invocation.

A decorating RemoteInvoker with an access to an EventLoop could create
Future/Promise and schedule a task, which will be useful when building
an advanced decorator such as a circuit breaker.

Modifications:

- Add EventLoop parameter to RemoteInvoker.invoke()
- Determine the EventLoop to perform the invocation in
  ClientInvocationHandler instead of in HttpRemoteInvoker
  - Move HttpRemoteInvoker.eventLoop() to ClientInvocationHandler
- Reorder the methods in HttpRemoteInvoker for readability

Result:

A decorating RemoteInvoker now has an access to the EventLoop which will
perform the actual invocation.
@trustin trustin added this to the 0.12.0.Final milestone Mar 7, 2016
return ServiceInvocationContext.mapCurrent(ServiceInvocationContext::eventLoop, eventLoopGroup::next);
private KeyedChannelPool<PoolKey> pool(EventLoop eventLoop) {
KeyedChannelPool<PoolKey> pool = map.get(eventLoop);
if (pool != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a question, why is this needed? computeIfAbsent should return immediately if present

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably to avoid the instantiation of the Function that's given as the second argument?

@synk
Copy link
Contributor

synk commented Mar 7, 2016

LGTM

synk added a commit that referenced this pull request Mar 7, 2016
Make EventLoop available to RemoteInvoker.invoke()
@synk synk merged commit bc7560b into line:master Mar 7, 2016
@trustin trustin deleted the remote_invoker_needs_event_loop branch March 7, 2016 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants