Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Demo code for the membership team's spike into step functions.

Notifications You must be signed in to change notification settings

guardian/awesome-step-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awesome Step Functions

Demo code for the membership team's spike into step functions.

Note: The word 'awesome' in the name refers to the Awesome Product team, not the awesomeness of the code, which, as Roberto pointed out, probably wouldn't justify that title 🐰.

Install and Run

Fire up sbt and type run.

There are two different apps included in this repo, so you will need to launch both of them separately. sbt figures this out and asks you which one you'd like to run. Launch the worker first and the supplier second (to avoid timeout issues).

You can see the result of the executions you create by looking at SimplesWorkerOne in the developer playground Step Functions console (accessible via Janus).

Explanation of the Code

Worker

The app in Worker.scala is the important bit in this demo code. It demonstrates how we can use the AWS Java SDK to implement a worker capable of communicating with a Step Functions State Machine, in order to process jobs.

This worker enters and indefinite loop and regularly polls the state machine for work. When there is a task to complete, the state machine sends the worker some JSON as input. When a task is complete, the worker replies to the state machine either with a success message that includes some JSON output, or with a simple failure message.

In the State Machine, activities are blueprints that describe possible tasks that a worker can subscribe to. In this app there is only one activity, but in a more realistic situation there are likely to be many. In this case we may want to create individual polling loops for each activity, and spin these up in different threads.

Supplier

The app in Supplier.scala is very basic, it's used to send JSON inputs up to state machines in order to kick off executions. These executions are what then provide jobs for the worker.

About

Demo code for the membership team's spike into step functions.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages