Created
June 16, 2014 20:34
-
-
Save jkodroff/20a47d8802cecac29938 to your computer and use it in GitHub Desktop.
How do I SOA?
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
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