Introduces the `decnet webhook` long-running worker that consumes the
internal bus and POSTs matching events to configured subscriptions.
Design: one task per (subscription, pattern) pair. Each task opens
its own bus subscription, iterates events, and dispatches via the
shared deliver() client. No intermediate queue, no in-memory filter
matching — the bus's own pattern matcher is the filter. Reloads on
`system.webhook.subscriptions_changed` signals from the CRUD router,
with a 60s fallback timer in case a signal is lost.
Shutdown propagates via CancelledError on the outer task; all inner
subscription tasks are cancelled and awaited in a finally block.
Bus unavailable → worker stays up in idle mode per the DEBT-031
pattern, logging one warning.
Registered as a master-only CLI command (agents don't configure
webhooks — the subscription store lives on master). systemd unit
mirrors the profiler template; added to decnet.target Wants= list so
`systemctl start decnet.target` brings it up alongside everything
else. `decnet init` auto-picks up the new .service.j2 via its
existing `glob("decnet-*.service.j2")` sweep.
19 lines
361 B
Python
19 lines
361 B
Python
"""Shared fixtures for webhook worker tests."""
|
|
from __future__ import annotations
|
|
|
|
from typing import AsyncIterator
|
|
|
|
import pytest_asyncio
|
|
|
|
from decnet.bus.fake import FakeBus
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def fake_bus() -> AsyncIterator[FakeBus]:
|
|
bus = FakeBus()
|
|
await bus.connect()
|
|
try:
|
|
yield bus
|
|
finally:
|
|
await bus.close()
|