Skip to content

Instantly share code, notes, and snippets.

@jkodroff
Created June 16, 2014 20:34
Show Gist options
  • Save jkodroff/20a47d8802cecac29938 to your computer and use it in GitHub Desktop.
Save jkodroff/20a47d8802cecac29938 to your computer and use it in GitHub Desktop.
How do I SOA?
POST file to /songs:
{
id: UUID,
bytes: byte[],
title: // blah blah
}
express method handle POST request:
put the POST data in the transcoding message queue with message type "encodeSong"
transcoding worker:
check the queue for encodeSong messages, if found:
send the request to AWS
save the saga with an ID (presumably the ID of the song since it has to be unique), and a status of "Requested"
another express handler for the AWS responses:
response comes in
forward the message on to the transcoding responses message queue (it's simplest to have each worker only work on 1 message type)
transcoding responses worker:
checks queue for awsEncodingResponse messages, if found:
finds the corresponding saga
if no saga found, throw an exception (because you got a response to something you apparently did not request)
if saga already complete, do nothing (idempotency)
(do whatever you do to the response)
mark the saga with a status of Complete
save the saga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment