Skip to content

Function definition namespaces (Importing several function definition files) #676

Closed
@fjtirado

Description

@fjtirado

As per spec "The functions property can be either an in-line function definition array, or an URI reference to a resource containing an array of functions definition. Referenced resource can be used by multiple workflow definitions."

This covers the following scenarios:

  • all function definitions to be used by an specific workflow are defined in the external file
  • all function definitions to be used are defined by the workflow itself.

But it does not cover two different scenarios that might arise:

  • using function definitions defined in multiple external files. Think of a file defining all functions for a particular api, another file defining all functions for another api and a workflow that orchestate the integration between these two APIS. Ideally you do not want to create a third file which merge the two others.
  • using an external file and adding specific functions for that particular workflow that wont be used in any other workflow. Ideally you do not want to update the external file with the private function

Therefore, I propose to update the Workflow specification to:

  • Establish that functions property can be only an array of function definitions (where all functions privative to that workflow are defined), but not an external reference.
  • Add a new property "namepaces" or "imports". That property will be an associative map, which value is the uri of a file containing array of function definitions and key is the namespace that identifies it within this workflow. The namespace is needed to avoid name clashing between different imported files. When calling the imported function within an state, the refName must have the namepace prefixed.

So, we will have something like in the header of the flow

"namespaces": {"myRpcAPI":"ARPCApi.json", "myOpenAPI": "OpenApi.json},
"functions": [{"name":"doSomething", "type": "expression", "operation":"jq  expression specific to this flow"}]

and

"refName": "myRpcAPI:doSomething"
"refName": "myOpenAPI:doSomething"
"refName":"doSomething"

Metadata

Metadata

Assignees

Labels

area: specChanges in the Specificationchange: featureNew feature or request. Impacts in a minor version change

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions