mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
refactor(automations): vertical-slice actions and triggers by domain
This commit is contained in:
parent
ce45e11009
commit
8c32455818
24 changed files with 86 additions and 108 deletions
23
surfsense_backend/app/automations/triggers/store.py
Normal file
23
surfsense_backend/app/automations/triggers/store.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""In-memory trigger registry. Populated once at process startup."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .types import TriggerDefinition
|
||||
|
||||
_REGISTRY: dict[str, TriggerDefinition] = {}
|
||||
|
||||
|
||||
def register_trigger(trigger: TriggerDefinition) -> None:
|
||||
"""Register a trigger. Raises on duplicate type."""
|
||||
if trigger.type in _REGISTRY:
|
||||
raise ValueError(f"Trigger already registered: {trigger.type!r}")
|
||||
_REGISTRY[trigger.type] = trigger
|
||||
|
||||
|
||||
def get_trigger(trigger_type: str) -> TriggerDefinition | None:
|
||||
return _REGISTRY.get(trigger_type)
|
||||
|
||||
|
||||
def all_triggers() -> dict[str, TriggerDefinition]:
|
||||
"""Defensive snapshot of the registry."""
|
||||
return dict(_REGISTRY)
|
||||
Loading…
Add table
Add a link
Reference in a new issue