spakky-celery¶
Celery 통합 — 태스크 디스패치, 스케줄링
Main¶
spakky.plugins.celery.main
¶
Plugin initialization entry point.
initialize(app)
¶
Initialize the Celery plugin.
Registers CeleryConfig, CeleryPostProcessor, and task dispatch aspects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
SpakkyApplication
|
The SpakkyApplication instance. |
required |
Source code in plugins/spakky-celery/src/spakky/plugins/celery/main.py
options: show_root_heading: false
Aspects¶
spakky.plugins.celery.aspects.task_dispatch
¶
AOP aspects for intercepting @task method calls and dispatching them to Celery.
CeleryTaskDispatchAspect(celery)
¶
Bases: IAspect, IApplicationContextAware
Intercepts synchronous @task method calls and dispatches them to Celery broker.
All @task method calls from outside Celery context are dispatched via send_task(). Inside a Celery worker, calls execute directly to avoid re-dispatch loops.
Initialize with the Celery application instance.
Source code in plugins/spakky-celery/src/spakky/plugins/celery/aspects/task_dispatch.py
set_application_context(application_context)
¶
Store the application context for checking worker context.
AsyncCeleryTaskDispatchAspect(celery)
¶
Bases: IAsyncAspect, IApplicationContextAware
Intercepts asynchronous @task method calls and dispatches them to Celery broker.
All @task method calls from outside Celery context are dispatched via send_task(). Inside a Celery worker, calls execute directly to avoid re-dispatch loops.
Initialize with the Celery application instance.
Source code in plugins/spakky-celery/src/spakky/plugins/celery/aspects/task_dispatch.py
set_application_context(application_context)
¶
Store the application context for checking worker context.
options: show_root_heading: false
Configuration¶
spakky.plugins.celery.common.config
¶
Celery configuration.
CelerySerializer
¶
Bases: str, Enum
Celery message serialization formats.
CeleryConfig()
¶
Bases: BaseSettings
Celery plugin configuration loaded from environment variables.
Initialize config from environment variables.
Note: This override is required for Spakky's @Configuration decorator to work with Pydantic BaseSettings. The decorator analyzes init parameters as dependencies, and BaseSettings' default init has a pydantic_self parameter that Spakky cannot resolve.
Source code in plugins/spakky-celery/src/spakky/plugins/celery/common/config.py
app_name = 'spakky-celery'
class-attribute
instance-attribute
¶
Celery application name.
broker_url
instance-attribute
¶
Celery broker URL (e.g., 'amqp://user:pass@host:5672//').
result_backend = None
class-attribute
instance-attribute
¶
Celery result backend URL. None disables result storage.
task_serializer = CelerySerializer.JSON
class-attribute
instance-attribute
¶
Serializer for task messages.
result_serializer = CelerySerializer.JSON
class-attribute
instance-attribute
¶
Serializer for task results.
accept_content = [CelerySerializer.JSON]
class-attribute
instance-attribute
¶
Accepted content types for deserialization.
timezone = 'UTC'
class-attribute
instance-attribute
¶
Timezone for scheduled tasks (IANA timezone, e.g., 'UTC', 'Asia/Seoul').
enable_utc = True
class-attribute
instance-attribute
¶
Use UTC for internal datetime handling.
options: show_root_heading: false
Task Result¶
spakky.plugins.celery.common.task_result
¶
Celery-backed implementation of TaskResult.
CeleryTaskResult(result)
¶
Bases: AbstractTaskResult[T], Generic[T]
Wraps a Celery AsyncResult, exposing the broker-agnostic TaskResult interface.
Wrap a Celery AsyncResult.
Source code in plugins/spakky-celery/src/spakky/plugins/celery/common/task_result.py
options: show_root_heading: false
Post Processor¶
spakky.plugins.celery.post_processor
¶
Post-processor for registering TaskHandler methods as Celery tasks.
CeleryPostProcessor
¶
Bases: IPostProcessor, IApplicationContextAware
Post-processor that registers TaskHandler-annotated Pods as Celery tasks.
set_application_context(application_context)
¶
Store the application context for resolving handlers at runtime.
post_process(pod)
¶
Register TaskHandler methods as Celery tasks and beat schedules.
Source code in plugins/spakky-celery/src/spakky/plugins/celery/post_processor.py
options: show_root_heading: false
Errors¶
spakky.plugins.celery.error
¶
options: show_root_heading: false