Spout¶
Core Spout class
Spout
¶
Bases: Task
Base class for all spouts.
__call__(method_name, *args, **kwargs)
¶
Execute a method locally and manage the state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method_name |
str
|
The name of the method to execute. |
required |
*args |
Positional arguments to pass to the method. |
()
|
|
**kwargs |
Keyword arguments to pass to the method. Keyword Arguments: - Additional keyword arguments specific to the method. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of the method. |
__init__(output, state, id=None, **kwargs)
¶
The Spout class is a base class for all spouts in the given context.
It inherits from the Task class and provides methods for executing tasks
both locally and remotely, as well as managing their state, with state management
options including in-memory, Redis, PostgreSQL, and DynamoDB,
and output data for batch or streaming data.
The Spout class uses the Output and State classes, which are abstract base
classes for managing output data and states, respectively. The Output class
has two subclasses: StreamingOutput and BatchOutput, which manage streaming and
batch output data, respectively. The State class is used to get and set state,
and it has several subclasses for different types of state managers.
The Spout class also uses the ECSManager and K8sManager classes in the execute_remote method,
which are used to manage tasks on Amazon ECS and Kubernetes, respectively.
Usage
- Create an instance of the Spout class by providing an Output object and a State object.
- The Output object specifies the output data for the spout.
- The State object handles the management of the spout's state.
Example
output = Output(...) state = State(...) spout = Spout(output, state)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output |
Output
|
The output data. |
required |
state |
State
|
The state manager. |
required |
create(klass, output_type, state_type, id=None, **kwargs)
staticmethod
¶
Create a spout of a specific type.
Parameters:
Returns:
| Name | Type | Description |
|---|---|---|
Spout |
Spout
|
The created spout. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid output type or state type is provided. |