Define a Corticon.js Service Callout
- Last Updated: April 5, 2023
- 2 minute read
- Corticon.js
- Documentation
- Metadata definition
- Service callout function implementation
- Configure runtime properties
- Export actions
Metadata definition
|
The metadata definition has the following fields:
- func (required) - The actual functional definition of the service callout code that gets executed at runtime by the Corticon engine.
- type (required) -
ServiceCalloutA string value that defines the type required by a Corticon.js Studio Service Callout. - description - Object, where the keys are locales (as strings) and the values
are localized strings used for the description of the service callouts. For example,
an entry to the US English localized name:
{'en_US': 'updates the entity'}The description gets displayed in Corticon.js Studio. - extensionType (required) -
SERVICE_CALLOUT- The extension type for a service callout in case sensitive textSERVICE_CALLOUT. If the extension type is not defined, the Corticon.js Studio will not see it as a service callout. - name(required) - Object, where the keys are locales (as strings) and the
values are localized strings used for the name For example, the US English localized
name.
{ 'en_US': 'updateData' }
Service Callout function implementation
updateCargoEntity, so
the function should also have that name. Here is an example of the service callout
function that gets entities by type Cargo, and then updates the volume
of the Cargo that has the container oversize:
|
Configure runtime properties
You can add properties to the service callout so that, for example, when a REST service needs authentication, you can pass in credentials as part of the configuration that just sits in the wrapper, and then propagates the configuration to the service callout. These properties are outside the bundle, in the wrapper. That means that you do not need to redeploy the decision service every time you want to, say, change the log level from 0 to 1. These are overrides to the properties in a Ruleflow that are static service callout settings.
As configuration runtime properties, you can have your own encryption-decryption mechanisms. You can pass in your secret. You will need to have your decryption logic in your service callout function that can read these properties, and then use them as needed in your service callout function. Configuration runtime properties are not embedded in the decision service bundle JavaScript file.
Export actions
|
The completed definition
|