AWS News Blog

AWS Flow Framework for Ruby for the Simple Workflow Service

The Amazon Simple Workflow Service (SWF) lets you build scalable, event-driven systems that coordinate work across many machines that can be either cloud-based or on-premises. The service handles coordination, logging, and auditing so that you don’t need to write a bunch of glue code or to maintain your own state machines. Instead, you can focus on the business logic that adds value and makes your business unique.

Today we are announcing a Ruby version of the AWS Flow Framework to make it even easier for you to write and manage your workflow logic in pure Ruby. Using the framework, you can write code in a straightforward way. Flow’s pre-built objects and classes will communicate with the Simple Workflow API on your behalf, making it easy for you to run tasks in sequence or in parallel on one or more machines. The framework tracks the progress of each step and retries failed tasks based on rules you define. Under the covers, it uses Amazon SWF for state management and for distributing tasks across worker machines. 

The Ruby version of the AWS Flow Framework is open source and available on GitHub. Get the gems from Rubygems and install them by typing gem install aws-flow. This will also install the AWS SDK for Ruby.

You construct your application by extending base classes provided by the framework. For example, to write a workflow that controls a flow of steps known in Amazon SWF as Activities you would write:

class HelloWorldWorkflow
   extend AWS::Flow::Workflows

  workflow :hello_workflow do
  {
    :version => “1”,:execution_start_to_close_timeout => 3600, :task_list => $TASK_LIST
  }
  end

  activity_client(:activity) { {:from_class => “HelloWorldActivity”} }

   def hello_workflow(name)
     activity.hello_activity(name)
   end
end

You can then write or reuse your existing Ruby code for the individual steps:

def hello_activity (name )
puts “Hello, #{name}!”
end

We have created a video tutorial to help you get started:

You can also download the Amazon SWF code samples, or read the Flow Framework Developer Guide to learn more.

— Jeff;