Add durable search event indexing contract
This commit is contained in:
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from typing import Literal, Protocol, runtime_checkable
|
||||
|
||||
from govoplan_core.core.events import PlatformEvent
|
||||
from govoplan_core.core.external_references import ExternalObjectReference
|
||||
from govoplan_core.core.modules import ModuleContext
|
||||
|
||||
@@ -379,6 +380,43 @@ class SearchSourceProvider(Protocol):
|
||||
"""Return an explicit decision for every requested reference key."""
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SearchEventSourceProvider(Protocol):
|
||||
"""Optional source extension for committed, idempotent index deltas."""
|
||||
|
||||
def index_changes_for_event(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
event: PlatformEvent,
|
||||
delivery_key: str,
|
||||
) -> Sequence[SearchIndexChange]:
|
||||
"""Translate one committed event into authoritative index changes."""
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SearchIndexCoordinator(Protocol):
|
||||
"""Worker-facing orchestration surface exposed by the Search module."""
|
||||
|
||||
def ingest_event(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
event: PlatformEvent,
|
||||
delivery_key: str,
|
||||
) -> Mapping[str, int]:
|
||||
...
|
||||
|
||||
def process_changes(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
limit: int = 100,
|
||||
tenant_id: str | None = None,
|
||||
) -> Mapping[str, int]:
|
||||
...
|
||||
|
||||
|
||||
SearchProviderFactory = Callable[[ModuleContext], SearchProvider]
|
||||
SearchSourceProviderFactory = Callable[
|
||||
[ModuleContext],
|
||||
@@ -455,8 +493,10 @@ __all__ = [
|
||||
"SearchBackfillRequest",
|
||||
"SearchContextKind",
|
||||
"SearchDocument",
|
||||
"SearchEventSourceProvider",
|
||||
"SearchIndexChange",
|
||||
"SearchIndexChangeKind",
|
||||
"SearchIndexCoordinator",
|
||||
"SearchIndexWriter",
|
||||
"SearchProvider",
|
||||
"SearchProviderFactory",
|
||||
|
||||
Reference in New Issue
Block a user