chaps-io/gush

Can I create a dynamic workflow based on job's output?

MiguelCorti opened this issue · 1 comments

Hey! Not actually an issue, more of a question really.

So the question is: can I run a job only if it meets a condition based on the output of a previous job (inside the workflow)? It sounds a bit too dynamic to me hahah.

I'm thinking something among the lines of:

class PublishBookWorkflow < Gush::Workflow
  def configure(url, isbn)
    id = run FetchBook, params: { url: url }
    job = find_job(id)
    if job.output == "fetched_with_success"
      run PublishBook, params: { book_isbn: isbn }
    end
  end
end

Although it does not seem doable this way, as the workflow probably won't have the output at that point in time. Maybe something like this:

class PublishBookWorkflow < Gush::Workflow
  def configure(url, isbn)
    run FetchBook, params: { url: url }
    run PublishBook, params: { book_isbn: isbn }, after: FetchBook, if: -> {previous_job.output == "fetched_with_success"}
  end
end

Or should I just check these conditions directly at the start of PublishBook's perform?

Thanks!
Awesome gem by the way.

You probably found an answer but Gush wasn't meant fo create dynamic workflows. So the answer is no :)