Persistence: - one delivery state per sink, with claim, crash recovery, and index replacement - retention for delivered and dead records - LMDB writes moved off the event loop Pipeline: - one attempt per dispatch, with the next try scheduled by next_retry_at - backpressure through max_queue_size - reload re-reads YAML; SIGTERM drains and SIGHUP reloads Plugins: - journald source, enricher and filter processors, Loki sink - built-ins register when entry points are missing API and CLI: - health, metrics, per-sink queue, and dead-letter replay - startup prints the pipeline on one line Tests: - dispatch, plugins, metrics, CLI, and persistence coverage
72 lines
1.5 KiB
Python
72 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Iterator
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
import yaml
|
|
|
|
from daena.config import DaenaConfig
|
|
from daena.persistence.lmdb import LMDBBackend
|
|
from daena.persistence.models import StoredRecord
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_db_path(tmp_path: Path) -> Path:
|
|
return tmp_path / "lmdb"
|
|
|
|
|
|
@pytest.fixture
|
|
def lmdb_backend(tmp_db_path: Path) -> Iterator[LMDBBackend]:
|
|
backend = LMDBBackend(
|
|
path=str(tmp_db_path),
|
|
map_size=10_485_760,
|
|
)
|
|
backend.open()
|
|
yield backend
|
|
backend.close()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_record() -> StoredRecord:
|
|
return StoredRecord(
|
|
source="test_source",
|
|
record_type="test",
|
|
body={"message": "hello"},
|
|
metadata={"env": "test"},
|
|
sinks=["out"],
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def minimal_config() -> DaenaConfig:
|
|
return DaenaConfig()
|
|
|
|
|
|
@pytest.fixture
|
|
def config_file(tmp_path: Path) -> Path:
|
|
path = tmp_path / "daena.yaml"
|
|
data = {
|
|
"data_dir": "/tmp/daena_data",
|
|
"logging": {"level": "debug", "format": "json"},
|
|
"sources": [
|
|
{
|
|
"name": "test",
|
|
"type": "dummy",
|
|
"enabled": True,
|
|
"options": {"interval": 1.0},
|
|
}
|
|
],
|
|
"sinks": [
|
|
{
|
|
"name": "output",
|
|
"type": "dummy",
|
|
"enabled": True,
|
|
"options": {},
|
|
}
|
|
],
|
|
}
|
|
with open(path, "w") as f:
|
|
yaml.dump(data, f)
|
|
return path
|