> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step.md).

# Event Step

Event steps pass event payload to an event handler, to execute selected action with given parameters.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2Fgz50hqriN0vUx0vsCsL2%2Fimage.png?alt=media&amp;token=4942d90b-6c6d-4b5d-883e-526b1fb0a609" alt="Event Step Definition"><figcaption><p>Event Step Definition</p></figcaption></figure>

Dragging and dropping an event step from the icon bar of a saga adds a new step. It is possible to configure each step clicking on the edit icon displayed when hovering its node. The following fields are used for overall settings of the step:<br>

* **Name:** Descriptive name of the step, which will be displayed on the saga flow.
* **Auto Fail:** Whether failure of this step should automatically fail the whole saga flow. If not set to true (or the saga itself has auto fail setting), error status should be handled separately.
* **Continue on Fail:** Whether this step should continue despite failing, in case the saga itself is set to "Auto Fail".
* **Description:** Verbal description of the step, for reference and documentation.
* **Stroke:** Color to use for drawing borders of the step, for visual purposes.
* **Fill:** Color to use for filling the step node, for visual purposes.
* **ID:** ID of the step used for reference in logs.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FQtmUaBUx5BDxRk6xSn4q%2Fimage.png?alt=media&amp;token=aecc2562-000a-4c91-8a35-72bc9735f7d9" alt="Event Step Metadata"><figcaption><p>Event Step Metadata</p></figcaption></figure>

The actual functionality of an event step is defined using event metadata settings listed below:<br>

* **Event Handler:** Alias of the event handler that should be used for calling a function on the runner receiving this event (e.g. read). This is an optional setting in some cases, as runners can match handlers to events based on streams the requests are received from. However, if the event is being processed locally (e.g. on "local" stream), this setting should be explicitly defined.
* **Event Version\*:** Numerical version of the action implementation to be used. Handlers allow versioning of their functions (i.e. actions) with new releases, so this setting defines which version should be used for a specific request. This is a mandatory setting, which should be set to 0 for unversioned actions.
* **Event Action\*:** Name of the function to be called on target event handler (e.g. Get) or alias of the preconfigured action on target runner (e.g. GetProduct). This is a critical setting, as it specifies actual action to execute for the step.
* **Event Domain:** Alias of a state, query or a system, which is used as the main target for event action (e.g. "Get" from "product" state). The meaning of this setting depends on the event handler configuration itself.
* **Input Element:** Json path for the data input from event payload (e.g. parameters). This parameter allows using events with different formats as input to the same event handler. If no input element is provided, full payload is used as the input.
* **Output Element:** Json path for the data output on event payload (e.g. list). This parameter allows outputing to different paths based on output format required by the API endpoint or the next saga step. If an input element is given, output element is relative to that path. If the output element starts with '$.', it is relative to the root of event payload, ignoring input element setting. If the output element is '-', it is ignored and no data is added to event payload as the output.
* **Action Specific Parameters:** Based on the "Event Action" selected, a number of additional parameters are displayed dynamicall (such as URL for a Call Rest action).

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FduxF4H6KwWzLEEnvOjLB%2Fimage.png?alt=media&amp;token=50e68114-26ae-43f3-9808-1532dfbac603" alt="Event Step Advanced"><figcaption><p>Event Step Advanced</p></figcaption></figure>

In addition to action specific parameters, all event steps allow configuration of some additional properties, displayed under ADVANCED tab:

### Common Action Parameters

Some actions support the following optional parameter groups. Each action page identifies the groups it supports.

#### Caching

| Parameter         | Definition                                            | Example               | Default |
| ----------------- | ----------------------------------------------------- | --------------------- | ------- |
| Use Cache         | Whether this event should use the cache               | `true`                | `false` |
| Cache State       | Name of the state manager used for caching event data | `product_cache`       | -       |
| Cache Key Pattern | JMESPath expression that produces the cache key       | `join([id, version])` | -       |

#### State access

| Parameter         | Definition                                                                       | Example | Default |
| ----------------- | -------------------------------------------------------------------------------- | ------- | ------- |
| Skip Access Query | Reads or writes directly, without falling back to the query defined on the state | `true`  | `false` |

#### Write response form

| Parameter | Definition                                                       | Example | Default |
| --------- | ---------------------------------------------------------------- | ------- | ------- |
| Form      | Form of response to produce. `full` includes custom data fields. | `full`  | `full`  |

#### Secret key generation

| Parameter            | Definition                                                               | Example | Default |
| -------------------- | ------------------------------------------------------------------------ | ------- | ------- |
| Generated Key Length | Length of the generated key when `keyId` does not exist in the key state | `32`    | `32`    |

* **Common Parameters**
  * **Fire & Forget:** Allows submitting action without waiting for its result. In this scenario the step only returns a reference ID, and returns before any processing happens. Fire-forget steps never fail, and results of the step needs to be monitored from a separate state.
  * **Log Detail:** Defines whether payload details should be fully logged regardless of the current log level. Recommended on development environments only, since can result in logging sensitive data in some cases.
  * **Ignore Errors:** Comma separated list of Rierino error codes to ignore (e.g. allowing STALE update errors on write actions).
  * **Delay Ms:** Milliseconds to wait between executing actions (e.g. for rate limiting on target systems).
  * **Delay ID:** Unique identifier of the actions which should wait each other with "Delay Ms".
  * **Meta Path:** Json element path in payload for pulling full event metadata dynamically.
  * **Parameters Path:** Json element path in payload for pulling parameters dynamically.
* **Iteration Parameters**
  * **Loop For Each Input:** Whether the action will be repeated for each record in input element (should be an array)
  * **Loop In Parallel:** Whether the loop will be executed in parallel faster using more resources
  * **Inner Input Element:** Json path for the inner element to use in a for each loop (inside main input element)
  * **Inner Output Element:** Json path for the inner element to output to in a for each loop (inside main output element)
  * **Pass Root From:** Section of the event payload to pass as root, instead of replicating full payload on each iteration
  * **Pass Root As:** Data path to pass root elements to for each loop (defaults to "$root"). Use "-" to exclude root from loops.
  * **Pass Index As:** Data path to pass index of row to for each loop (defaults to "$index"). Use "-" to exclude root from loops.
  * **Return Full Result:** Whether iterations should return full payload or only the output element values
* **Full Parameter Map:** Includes a table of all parameters configured.
* **Response Stream**
  * **Deployments:** List of runner deployment ids which are allowed to execute this step. This is required when more than one runner deployment exists (e.g. v1, v2). If the deployment id is not specified in such scenario, both runners would process the same event, resulting in duplicate actions and responses. This is a rare case, typically used when deploying a new runner version while the old version is still running to avoid downtime (e.g. changing deployment id only after new version is up and running).
  * **Inject:** Whether these settings (e.g. input element, domain, etc.) should allow injection of key-value parameters and secrets or not.
  * [**Follow Ack**](#user-content-fn-1)[^1]**:** Whether event status ACK should continue saga flows [instead of immediately returning](#user-content-fn-2)[^2]
  * **Response System:** Alias of the system for the receiving runner to reply on. This setting is used when communication is through an event streaming platform (e.g. Kafka) and the response should be sent through a system different than the default.
  * **Response Stream:** Alias of the stream for the receiving runner to reply on. This setting is used when communication is through an event streaming platform (e.g. Kafka) and the response should be sent through a stream different than the default.

These settings work similar to a remote function call, where the handler and action define target function and other settings define its parameters for execution.

{% hint style="info" %}
An event step can be executed locally or sent out to other runners for async and more scalable execution, orchestrating multiple microservices.
{% endhint %}

### Event Validators

Similar to sagas, event steps allow configuring custom pre/post validators for validating input and output payloads against custom logic.

## Event Step Data Schema

{% code expandable="true" %}

```json
{
		"eventMeta": {
			"type": "object",
			"description": "Event metadata defining details on the action call",
			"properties": {
				"handler": {
					"type": "string",
					"description": "Alias of the handler to be used for processing event step",
					"examples": ["read", "write", "query", "rest"]
				},
				"action": {
					"type": "string",
					"description": "Name of the action/function to call, which is specific to the handler selected",
					"examples": ["Get", "Create", "GetQuery", "CallRest"]
				},
				"domain": {
					"type": "string",
					"description": "Domain for which the action will be taken, which has a different meaning based on the action type (such as database table for Create action)"
				},
				"inputElement": {
					"type": "string",
					"description": "JSON path of the data field in event payload, which should be used as input for the action"
				},
				"outputElement": {
					"type": "string",
					"description": "JSON path of the data field where outputs of the action should be writted on. Output element uses input element as the root and creates children below that root, unless output element starts with $, which refers to the event payload making it the root."
				},
				"parameters": {
					"type": "object",
					"description": "Key-value pair parameters used by the specific action type (such as inputPattern for Create action)"
				}
			}
		}
	}
```

{% endcode %}

## Using Preconfigured Actions

While it is possible to define all settings for each event step inside a saga, especially for high volume and low latency requirements, it may be preferrable to define default values once and reuse them for each call.

There are 3 alternative ways of achieving this, which can be also combined together based on the use case:

1. Defining predefined "Action" records and using [Execute Predefined Actions](https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step/flow-actions/execute-predefined-actions.md#execute-predefined-actions) handler to call them.
2. Defining structural [Actions](https://docs.rierino.com/devops/microservices/building-blocks/additional-elements/actions.md) runner elements with the default values and using them as event actions for requests to runners with these elements.
3. Defining metadata overrides to streams through which these action requests are sent to the target event runners.

This approach has 2 main benefits:

1. Not sending the same list of settings with each request decreases the size of data transferred and stored.
2. It becomes possible to update the list of parameters used for same type of request across all sagas at once.

[^1]: Since 0.5.0

[^2]: E.g. for TaskEventHandler, whether to return immediately, or allow custom logic in saga flow design using ACK event status with a condition step


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
