Tasks
Heimdall Register - Event-Driven Task Triggering
Register tasks with Heimdall to execute actions based on event triggers
Heimdall Paths and Mechanisms form the basis of the registration task and are explained further in the Heimdall documentation.
Basic usage
In the following example, we are registering a task using Heimdall to update the subject of a stub every time a customer's balance is updated. This task will be triggered whenever the specified event occurs.
Detailed Description
Task Type
tasktype
: Specifies the type of task to be registered. In this case, it is a Heimdall task registration.
Parameters (params)
uuid
: A unique identifier for the task, generated deterministically using the stub reference. This ensures that the same task has the same UUID every time it is registered.
{{#deterministicuuid stub.stubref}}{{/deterministicuuid}}
: Template syntax used to generate the UUID based on the stub reference.
registration_name
: A human-readable name for the task registration. In this case, it's namedheimdall_customer_account_balance_update
to reflect the nature of the task.on_trigger_method
: Specifies how the task should behave when triggered. The valuekeep
indicates that the task should remain registered and active even after being triggered.
Events (events) This section defines the events that will trigger the task. In this example, it listens for updates to customer account balances.
wait_for_customer_account_balance
:path
: The event path that the task will listen to. It monitors updates to the balance of customer accounts. The[CUSTOMER_ACCOUNT_ID]
placeholder will be dynamically replaced with the actual customer account ID.mechanism
: Specifies the event mechanism. Here,evt
indicates that the event is an asynchronous event.timeout_seconds
: Defines the timeout period for the event in seconds. In this case, the timeout is set to 3600 seconds (1 hour).
Trigger Stub Action (trigger_stubaction) This section defines the action to be performed when the event is triggered.
action_name
: The name of the action to be executed._set_subject_on_stub
is a predefined action that sets the subject on a stub.stubref
: A reference to the stub that will be updated.~~stub.stubref
uses a template to dynamically reference the stub.data
: Contains the data to be used in the action.subject
: The new subject to be set on the stub. It uses template syntax to include the customer account ID and the updated balance.
{{stubpost.data.customer_account_id}}
: Template placeholder for the customer account ID.
{{stubpost.data.balance}}
: Template placeholder for the updated account balance.
Parameters
required string
uuid The unique identifier of linked to this particular Heimdall registration.
required string
registration_name The human readable name of the registration. This is used to identify the registration.
optional string
on_trigger_method The method to use when the trigger is fired. Allows the user to specify whether to keep or remove the registration when the trigger is fired.
Options: keep
| remove
required string
events.[event_name].path This is the path that will be monitored for triggers. * can be used as a wildcard in the path.
See also: Heimdall
required string
events.[event_name].mechanism The mechanism to use to fire the trigger.
Options: evt
| cbh
| rra
| rnd
| evb
See also: Heimdall
required integer
events.[event_name].timeout_seconds The number of seconds that the registration will be active for. After this time the registration will be removed.
required string
trigger_stubaction.action_name The name of the stub action to trigger when the registration is fired.
required string
trigger_stubaction.stubref The stubref of the stub to trigger the action on.
required object
trigger_stubaction.data The data to pass to the stub action when it is triggered.
required string
trigger_stubaction.message The stub post message to pass to the stub action when it is triggered.
Result
Examples
Here are some more complex examples:
Send an minutely update to a stub
Task
See also: Heimdall: Standard Emitters