fredjean / simpler_workflow

Wrapper for Amazon's Simple Workflow Service
MIT License
41 stars 7 forks source link

How to get last activity name? #9

Open davidpelaez opened 11 years ago

davidpelaez commented 11 years ago

Hi,

I have an on_activity_completed do |task, event| but I don't know how to find the name of the task that just completed. Your gem is by far the cleaneast and easiest SWF solution to use. The recently released aws-flow is so complicated and messy. But I'm stuck and I can't figure out how to write logic in the decider based on what task completed.

Thanks for your work, it's very helpful to have it available.

PS: If there's a better place to put this question please let me knkow.

fredjean commented 11 years ago

Here's how I normally do it:

  decision = register_workflow("hello-world", "1.0.1") do
    initial_activity :hello, "1.0.0"

    on_activity_completed do |task, event|
      completed_event = scheduled_event(task, event)
      case completed_event.attributes.activity_type.name
      when "hello"
        task.schedule_activity_task record.to_activity_type, :input => event.attributes.result
      when "record"
        task.complete_workflow_execution :result => 'success'
      end
    end
  end

(from fredjean/swf_example )

Let me know if this helps....

Would it be a good idea to add a method that makes it easier to pull out?