symfonic.infra.protocols¶
protocols ¶
TaskSchedulerProtocol -- abstract interface for background task scheduling.
The library depends only on this protocol. Concrete adapters (Celery, APScheduler, etc.) live in the application layer and are injected at runtime via dependency inversion.
NullScheduler is the default implementation that silently discards
all task requests, ensuring the library works standalone without any
external scheduler.
NullScheduler ¶
No-op scheduler that silently discards all task requests.
Used as the default when no external scheduler is configured, ensuring the library functions standalone without Celery or any other task infrastructure.
cancel_task
async
¶
enqueue_task
async
¶
Accept and discard the task request.
Source code in src/symfonic/infra/protocols.py
schedule_recurring
async
¶
schedule_recurring(
task_name: str,
interval_seconds: float,
params: dict[str, Any] | None = None,
) -> str
Accept and discard the recurring schedule request.
Source code in src/symfonic/infra/protocols.py
TaskSchedulerProtocol ¶
Bases: Protocol
Abstract interface for background task scheduling.
All methods accept a task_name string that the adapter maps
to a concrete task implementation (e.g. a Celery task, an
APScheduler job, etc.).
cancel_task
async
¶
Cancel a previously enqueued or recurring task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
str
|
The identifier returned by |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the task was found and cancelled, False otherwise. |
Source code in src/symfonic/infra/protocols.py
enqueue_task
async
¶
Enqueue a task for immediate background execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Identifier for the task to execute. |
required |
params
|
dict[str, Any] | None
|
Optional keyword arguments for the task. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A task ID string that can be used with |
Source code in src/symfonic/infra/protocols.py
schedule_recurring
async
¶
schedule_recurring(
task_name: str,
interval_seconds: float,
params: dict[str, Any] | None = None,
) -> str
Schedule a task to run repeatedly at a fixed interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_name
|
str
|
Identifier for the task. |
required |
interval_seconds
|
float
|
Seconds between successive executions. |
required |
params
|
dict[str, Any] | None
|
Optional keyword arguments for each invocation. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A task ID string for cancellation. |