-
Notifications
You must be signed in to change notification settings - Fork 62
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
server side concurrency #49
Conversation
It carries informations about a request when being handled server side. The goal is to simplify concurrency implementation
instead of calling it separately for each method
The unmarshalling is now done the same way it is done for other methods.
64aad3e
to
9f435ef
Compare
This function takes care of sending the reply after running the handler. To keep the prometheus metrics, a AfterReply callback was added on the request.
Handlers can optionnally be initialized with a WorkerPool that controls how many concurrent calls can be handled, and how many pending requests can be queued.
If a request is pending for more than the maxPendingDuration, the scheduler send a SERVERTOOBUSY to the caller. This way, an overloaded server will always reply something to the client, which reduces a lot the cases where it gets a timeout error. The maxPendingDuration should be short enough so that this duration plus the handling duration remains smaller than the client timeout. A next version of this system could cancel a running handler if its too long and send a reply 'server is too slow' to the client
I did a review with a colleague, and have a few more things to clean. Stay tuned. |
This saves a few more lines of generated code.
This is to be sure that scheduler() will never attempt to write to the schedule chan after its closed.
…ing tasks that the new queue size
…lf on RunAndReply
@mdevan I think I am done now. I will test the PR in my project this afternoon. |
Hi @mdevan |
8f49f70
to
58accd6
Compare
Thanks @mdevan for the detailed review. |
Implementation of #48.
The first 8 commits refactors the code in order to generate less code and simplify the concurrency implementation.
On side-effect is that a Request struct is now available in the context and provides access to all the request information.
The last commits implements concurrency.