Ability to call Functions as a service that active a camunda process.
Todos:
Design Notes
- Support POST (GET with a body is not supported by all http clients.)
- Body should be transformed into Camunda Variables. Use same format as Camunda Variables object
- Camunda
variablesInReturn
property should configure the returned API response
- Body
- Status Code
- headers
- Ability to call a BPMN based on key and based on ID. This configuration should be in the Service Type configuration. You should not be able to call any process you wish. Only processes that are exposed as a FaaS.
- BU owner of a FaaS service will be what controls the security access.
Use Cases
- First use case will be the ability for Formio forms to make requests to FaaS service for server side validations. Look into whether this should be a function call that is activated by Formio or by the Service Microservice.
Endpoint Examples:
POST /faas/key/:key
POST /faas/id/:id
{
"varName1": {"value":"the Value 1", "type":"String"},
"varName2": {"value":true, "type":"Boolean"}
}
Endpoint Styles
faas
func
function
camunda
Response handling
- When Camunda throws an error: If Camunda returns a error then it should be logged and the FaaS API returns a internal server error 500 response.
- Camunda will return the following:
- body
- status_code
- Headers? (json object?)
FaaS service type will convert this into a proper response.
All processing should be optimized for speed over elegance. Speed of response is priority.
If Camunda does not return the proper variables that Services Microservice will return a Internal Error
Considerations
- How should multiple validations be returned?
- body will have array of "errors" will be returned and be the list of errors.
- When complex logging should occur about errors, have the logging occur async after the response has been returned
- The Service MS will have to parse stringified json objects into proper json.
- question: should there be a debug mode (activated through query param) that returns full variable data / the raw response from Camunda?
- Status codes will have to be converted to proper format.
Samples
Variables in Camunda process:
response_body = [] or = {} (is valid JSON)
response_headers = [{"key": "value"}]
response_status_code = integer
For multiple errors:
The response_body
would be a SPIN Json array, and each error would append to the array.
For single error response scenarios, the json could return any style defined in the bpmn.
If Function/Process cannot be found then Function not found error response is returned
All other variables that would be returned by Camunda would be ignored.
Data Flow
- Validations should occur:
- Before Form Load,
- Before Form Submit or
- After Formio Validations.
This should occur as part of a configuration of the BPM Service.
- Only Next step is continued if proper status code is returned
example of Usage for:
Before Form Load:
- Check if user is currently to load this form
Before Form Submit:
- The user can see the form, but are they allowed to submit the form regardless of formio validations
After Formio Validation:
- Validate specific data in the form using server side validations beyond that of Formio
Before Form Load, Before Form Submit and After Formio Validation configurations should allow multiple processes to be called. and support weight/order to which they are called. OR at least allow all three options to be implemented. So that a single service can have a Before Load, Before Submit and After Formio processes.