Scripting an umpire and voters - GlueScript/Glue GitHub Wiki
The glue application, as it is now, scripts HTTP requests between services.
What about being able to script interactions that take place over an event queue or pub-sub channels?
- Script would enforce the rules that an Umpire service follows in order to "respond" to a request
Example: Authentication via voters
-
Umpire has rules that state that 3 voters must respond with 'success'
-
Account exists for email
-
Password matches
-
Account unlocked (not too many failed logins)
-
Umpire pops a fact on to the queue
{"type":"authentication.attempt", "email":"[email protected]", "password": "already-hashed", "poll-id":"ea31bf6c78"}
-
Account exists voter pulls this fact from the queue and looks up the email address
-
Account exists voter pops this fact back on the queue
{"type":"authentication.attempt.email.check", "email":"[email protected]", "password": "already-hashed", "poll.id":"ea31bf6c78", "account.id" : "http://account.net/1234", "state":"exists"}
-
Now that the account is identified the other voters can work in parallel
-
Password matches voter pulls this event from the queue and compares the password hash with that of "http://account.net/1234"
-
Account unlocked voter pulls this event from the queue and checks the locked state of "http://account.net/1234"
-
Password matches voter pops this fact back on the queue
{"type":"authentication.attempt.password.check", "email":"[email protected]", "password": "already-hashed", "poll.id":"ea31bf6c78", "account.id" : "http://account.net/1234", "state":"matches"}
-
Account unlocked voter pops this fact back on the queue
{"type":"authentication.attempt.account.state", "email":"[email protected]", "password": "already-hashed", "poll.id":"ea31bf6c78", "account.id" : "http://account.net/1234", "state":"unlocked"}
-
Umpire's rules state that it waits for the "authentication.email.exists", "authentication.password.matches" and "authentication.account.unlocked" facts and when all three are received for a single "poll.id" then it can respond to the original request.
Rules to govern this interaction could be
[
{
"type":"authentication.attempt.email.check",
"required":"true",
"state":"exists"
},
{
"type":"authentication.attempt.password.check",
"required":"true",
"state":"matches"
},
{
"type":"authentication.attempt.account.state",
"required":"true",
"state":"unlocked"
}
]
Wait for three facts with these types and these states, when they are received the poll is complete.