Toggle composer
Fluent Toggle builder for Composer.
This module defines ToggleComposer, a small builder used by Composer to add
a toggle conditional step fluently.
Note
This builder is not meant to be instantiated directly by users. Use
Composer.toggle(...) to obtain an instance and complete it with
.then(...) and .end().
References
NONE
ToggleComposer(parent, condition, output_state=None, input_map=None, retry_config=None, error_handler=None, cache_store=None, cache_config=None, name=None)
Fluent builder for a toggle conditional.
Usage
composer.toggle(condition).then(enabled_branch).end()
After setting the enabled branch, call .end() to append the toggle step and
return back to the parent Composer.
Initialize the ToggleComposer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent |
Composer
|
The parent composer instance. |
required |
condition |
Component | Callable[[dict[str, Any]], bool] | str
|
The condition to evaluate. |
required |
output_state |
str | None
|
Optional state key to store condition result. Defaults to None. |
None
|
input_map |
InputMapSpec | None
|
Unified input mapping for the condition. Defaults to None. |
None
|
retry_config |
RetryConfig | None
|
Retry configuration. Defaults to None. |
None
|
error_handler |
BaseStepErrorHandler | None
|
Error handler. Defaults to None. |
None
|
cache_store |
BaseCache | None
|
Optional cache store. Defaults to None. |
None
|
cache_config |
dict[str, Any] | None
|
Optional cache config. Defaults to None. |
None
|
name |
str | None
|
Optional name for the resulting step. Defaults to None, in which case a name will be auto-generated with the prefix "Toggle_". |
None
|
end()
Finalize and append the toggle step to the parent composer.
Returns:
| Name | Type | Description |
|---|---|---|
Composer |
Composer
|
The parent composer for continued chaining. |
then(branch)
Define the branch to execute when the condition is true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
branch |
BasePipelineStep | list[BasePipelineStep]
|
The step(s) for the enabled branch. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The builder instance for chaining. |