> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracecat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scatter-gather loops

## `core.transform.scatter`

Transform a collection of items into parallel execution streams, where each item is processed independently.

### Inputs

<ParamField path="collection" type="string | array[any]" required>
  The collection to scatter. Each item in the collection will be processed independently in its own execution stream. This should be a JSONPath expression to a collection or a list of items.
</ParamField>

<ParamField path="interval" type="number | null">
  The interval in seconds between each scatter task.

  Default: `null`.
</ParamField>

### Examples

**Fan out and collect results**

```yaml theme={null}
- ref: scatter_hosts
  action: core.transform.scatter
  args:
    collection: ${{ TRIGGER.hosts }}
- ref: check_host
  action: core.http_request
  depends_on:
    - scatter_hosts
  args:
    url: https://scanner.example.com/hosts/${{ ACTIONS.scatter_hosts.result.id }}
    method: GET
- ref: gather_results
  action: core.transform.gather
  depends_on:
    - check_host
  args:
    items: ${{ ACTIONS.check_host.result }}
    drop_nulls: true
    error_strategy: partition
```

## `core.transform.gather`

Collect the results of a list of execution streams into a single list.

### Inputs

<ParamField path="items" type="string" required>
  The JSONPath expression referencing the item to gather in the current execution stream.
</ParamField>

<ParamField path="drop_nulls" type="boolean">
  Whether to drop null values from the final result. If True, any null values encountered during the gather operation will be omitted from the output list.

  Default: `false`.
</ParamField>

<ParamField path="error_strategy" type="string">
  Controls how errors are handled when gathering. "partition" puts successful results in `.result` and errors in `.error`. "include" puts errors in `.result` as JSON objects. "drop" removes errors from `.result`. "raise" fails the gather if any branch errors.

  Default: `"partition"`.

  Allowed values: `partition`, `include`, `drop`, `raise`.
</ParamField>

### Examples

**Fan out and collect results**

```yaml theme={null}
- ref: scatter_hosts
  action: core.transform.scatter
  args:
    collection: ${{ TRIGGER.hosts }}
- ref: check_host
  action: core.http_request
  depends_on:
    - scatter_hosts
  args:
    url: https://scanner.example.com/hosts/${{ ACTIONS.scatter_hosts.result.id }}
    method: GET
- ref: gather_results
  action: core.transform.gather
  depends_on:
    - check_host
  args:
    items: ${{ ACTIONS.check_host.result }}
    drop_nulls: true
    error_strategy: partition
```
