mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
feat(automations): add event trigger source, selector and registration
This commit is contained in:
parent
4ba637ea44
commit
acd673023a
5 changed files with 157 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
"""Event trigger source: the bus subscriber that enqueues the selector.
|
||||
|
||||
Runs in whatever process published the event, so it stays thin — it only hands
|
||||
the event to a worker (the selector does the DB matching).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.event_bus import Event
|
||||
|
||||
TASK_NAME = "automation_event_select"
|
||||
|
||||
|
||||
async def on_event(event: Event) -> None:
|
||||
"""Enqueue the selector for ``event``."""
|
||||
# Lazy import: keeps app.celery_app out of the triggers-package import graph.
|
||||
from app.celery_app import celery_app
|
||||
|
||||
celery_app.send_task(TASK_NAME, kwargs={"event": event.model_dump(mode="json")})
|
||||
Loading…
Add table
Add a link
Reference in a new issue