Coverage for src / lexigram / contracts / data / outbox.py: 0%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-15 18:57 +0800

1"""Transactional outbox protocol for reliable event delivery.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any, Protocol, runtime_checkable 

6 

7from lexigram.contracts.domain.events import DomainEvent 

8 

9 

10@runtime_checkable 

11class OutboxStoreProtocol(Protocol): 

12 """Protocol for transactional outbox storage.""" 

13 

14 async def append_batch(self, events: list[DomainEvent]) -> None: 

15 """Write a batch of domain events to the outbox table atomically.""" 

16 ... 

17 

18 async def fetch_pending(self, limit: int = 100) -> list[dict[str, Any]]: 

19 """Fetch undelivered outbox events.""" 

20 ... 

21 

22 async def mark_delivered(self, event_id: str) -> None: 

23 """Mark an outbox event as successfully delivered.""" 

24 ... 

25 

26 async def mark_failed(self, event_id: str, error: str) -> None: 

27 """Mark an outbox event as permanently failed.""" 

28 ... 

29 

30 

31__all__ = [ 

32 "OutboxStoreProtocol", 

33]