Dynamic action workflows pattern


@nmaludy@shu discussed in the #community channel how to write a workflow that accepts an action and arguments to execute. I’m writing it up here so it’s not lost. This pattern works with Orquesta only.

nmaludy [1:21 PM] so, you could implement an existing StackStorm concurrency policy with concurrency: 1 in a single shu.business_logic workflow… this workflow can accept another workflow’s name as input… then one of your tasks can call that workflow dynamically using Orquesta

shu [1:24 PM]
Idea 1: Write wrapping workflow. And apply policy to that wrapping workflow. Minus: we need to update wrapping workflow when we add more workflows to get policed (This is because there is no way to dynamically decide which workflow to run inside workflow)

shu [1:34 PM] @nmaludy you are savior. THIS WORKS

$ cat dynamic_workflow.meta.yaml

enabled: true
name: dynamic_workflow
runner_type: orquesta
entry_point: workflows/dynamic_workflow.yaml
    type: string
    required: true
    default: core.noop
    type: object
    required: true

$ cat workflows/dynamic_workflow.yaml

version: 1.0

  - workflow_name
  - workflow_input

  - workflow_result: "{{ ctx().workflow_result }}"

    action: "{{ ctx().workflow_name }}"
    input: "{{ ctx().workflow_input }}"
      - publish:
          - workflow_result: "{{ result() }}"

(W Chan) #2

This has been added to our docs Added documentation about the dynamic execution pattern by nmaludy · Pull Request #134 · StackStorm/orquesta · GitHub.