-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permits client requests in any FSM state.
This commit adds a request queue to the shotgun FSM and three argument versions of each FSM state function whose only purpose is to ether stick valid client request data into the work queue and get back to waiting, or stop the FSM if the client request data was invalid. create_work/2 describes valid and invalid requests. This lets us have multiple callers -directly or indirectly- call shotgun:request while a gun request is still pending. Previously, if the call happened when we were in any state other than at_rest, the FSM would probably crash. This also means that if one's request times out, one can immediately re-submit that request without crashing shotgun. However, there *are* a few caveats: * shotgun only processes one request at a time. * Your new request is put on the end of the request queue. * Your *previous* request is not cancelled. If shotgun never got around to servicing it, or is not done servicing it, then your old request that you no longer care about will be serviced before your new request. * If the process that initiated a timed-out request is still alive, it will get a message in its mailbox when the request eventually succeeds. It also might get a message when the request eventually fails, I'm not sure. The guts of at_rest/3 have been moved to at_rest/2. at_rest/3 now only sticks client request data into the work queue and triggers the call of at_rest/2. Every transition from another state to at_rest now includes a timeout value of 0. The purpose of at_rest(timeout, State) is to check for work and either dispatch it to the FSM, or go back to the idle at_rest state.
- Loading branch information
1 parent
e63b2e7
commit 372539e
Showing
1 changed file
with
128 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters