I think it depends on how you need to map the serverless workflow dsl function definitions to your activities.
In SW workflow states you don’t define your function instructions, but reference them by name, for example:
"states":[
{
"name":"Greet",
"type":"operation",
"actions":[
{
"functionRef": "My Greeting Function"
}
],
"transition": "Next Workflow State..."
}
]
functionRef
is a reference to one of the functions you define in your functions
definition, for example:
"functions": [
{
"name": "My Greeting Function",
"operation": "http://myapis.org/applicationapi.json#greet",
"type": "rest"
}
]
note that function definitions can be completely externalized from the actual dsl workflow definition, so instead of defining all your functions inline, you can set them up in a separate json/yaml file and then in your workflow definition reference that file, for example:
"functions": "myfunctiondefinitions.json"
This makes your pre-defined function definitions reusable across multiple dsl workflow definitions.
Idea behind this was that if you have end users define your DSL workflows, you can provide them with pre-defined functions they can reference in their control flow logic (workflow states). Same is really for event definitions, retry definitions, etc.
If you allow your end users to define their own function definitions, meaning you do not know up-front how to map each of their defined function defs, then imo using DynamicActivity comes in really handy as it will make sure that you will map every single one of user-defined functions to activities, and then can use for example the operation and type params to determine what code needs to be called for that activity.
If you provide the functions to your end users, and force them to use these pre-defined function definitions, then you can set up all your activity implementations up-front and will know that you will have a mapping for every single one that user defines in their workflow states.
Being able to pre-define your function defs that your users are allowed to use has the advantage that you can have different configurations per activity, for example you can rate-limit them differently if needed, can provide separate retry policies etc. In case of using DynamicActivity you only have a single activity impl that you have to configure as a single one.
Hope this helps.