Event bus basics

This commit is contained in:
Piotr Dec 2025-10-31 00:01:45 +01:00
parent 1440ec51b7
commit 87e8af3f72
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
8 changed files with 88 additions and 16 deletions

View file

@ -3,6 +3,7 @@ import uuid
from typing import Annotated, List
from injectable import injectable, autowired, Autowired
from typing_extensions import deprecated
from app.core.queue import EnqueuedProcessor, ProcessQueue, Task, Result
from app.model.healthcheck import HealthCheck
@ -11,20 +12,19 @@ from app.services import DockerService, GitService, Passwords
logger = logging.getLogger(__name__)
@deprecated("Use event bus instead.")
@injectable(singleton=True)
class WebhookProcessor(EnqueuedProcessor):
class WebhookProcessor:
@autowired
def __init__(self, docker: Annotated[DockerService, Autowired],
git: Annotated[GitService, Autowired],
keepass: Annotated[Passwords, Autowired],
queue: Annotated[ProcessQueue, Autowired]):
super().__init__(queue)
keepass: Annotated[Passwords, Autowired]):
self._docker = docker
self._git = git
self._keepass = keepass
def enqueue(self, event: WebhookEvent):
self._enqueue(Task(uuid.UUID(), self, event))
pass
def _process(self, task: Task[WebhookEvent]) -> Result:
event: WebhookEvent = task.payload