edri package¶
Subpackages¶
- edri.abstract package
- edri.api package
- Subpackages
- edri.api.dataclass package
- edri.api.extensions package
- edri.api.grpc package
- edri.api.handlers package
- edri.api.headerkit package
- Submodules
- edri.api.headerkit.core module
- edri.api.headerkit.defaults module
- edri.api.headerkit.errors module
- edri.api.headerkit.grammar module
- edri.api.headerkit.parsers module
- edri.api.headerkit.policy module
- edri.api.headerkit.registry module
- edri.api.headerkit.response module
- edri.api.headerkit.types module
- Module contents
- Submodules
- edri.api.broker module
- edri.api.event_builder module
- edri.api.event_registry module
- edri.api.listener module
- edri.api.middleware module
- edri.api.pipes module
- Module contents
- Subpackages
- edri.cli package
- edri.config package
- edri.dataclass package
- Subpackages
- Submodules
- edri.dataclass.event module
- edri.dataclass.health_checker module
- edri.dataclass.injection module
- edri.dataclass.persistence_failure_policy module
- edri.dataclass.response module
- edri.dataclass.topology module
- edri.dataclass.worker module
- Module contents
- edri.events package
- edri.integrations package
- Subpackages
- edri.integrations.pydantic_ai package
- Submodules
- edri.integrations.pydantic_ai.agent module
- edri.integrations.pydantic_ai.inspector module
- edri.integrations.pydantic_ai.inspector_events module
- edri.integrations.pydantic_ai.inspector_store module
- edri.integrations.pydantic_ai.lifecycle module
- edri.integrations.pydantic_ai.mcp module
- edri.integrations.pydantic_ai.normalization module
- edri.integrations.pydantic_ai.observability module
- edri.integrations.pydantic_ai.worker module
- Module contents
- edri.integrations.sqlalchemy package
- Submodules
- edri.integrations.sqlalchemy.event module
- edri.integrations.sqlalchemy.filter module
- edri.integrations.sqlalchemy.middleware module
- edri.integrations.sqlalchemy.model module
- edri.integrations.sqlalchemy.path module
- edri.integrations.sqlalchemy.projection module
- edri.integrations.sqlalchemy.session module
- edri.integrations.sqlalchemy.sort module
- edri.integrations.sqlalchemy.validator module
- Module contents
- edri.integrations.pydantic_ai package
- Module contents
- Subpackages
- edri.protocol package
- edri.router package
- edri.switch package
- edri.utility package
- Subpackages
- Submodules
- edri.utility.cache module
- edri.utility.coercion module
- edri.utility.function module
- edri.utility.json_encoder module
- edri.utility.normalized_default_dict module
- edri.utility.queue module
- edri.utility.shared_memory_pipe module
- edri.utility.storage module
- edri.utility.transformation module
- edri.utility.validation module
- edri.utility.watcher module
- Module contents
Submodules¶
edri.testing module¶
Testing helpers for EDRI application tests.
This module provides lightweight helpers for writing unit tests against Manager handlers without launching child processes. It wraps internal setup steps so application tests can use public API only.
ManagerTestHarness is Experimental — it may be extended in minor
releases but breaking changes will follow the project's compatibility policy.
- class edri.testing.ManagerTestHarness(manager: ManagerBase)[source]¶
Bases:
objectWraps a Manager instance for unit testing.
Usage:
harness = ManagerTestHarness(MyManager(router_queue=mock_queue)) harness.prepare() event = MyEvent(...) harness.resolve(event) assert harness.get_status(event) == ResponseStatus.OK assert harness.get_directives(event) == []
All assertions use public API so tests survive internal refactoring.
- static get_directives(event: Event) list[ResponseDirective][source]¶
Return the directives attached to event's response.
- static get_status(event: Event) ResponseStatus[source]¶
Return the response status after resolving event.
- property manager: ManagerBase¶
Module contents¶
- class edri.EDRI[source]¶
Bases:
objectThe EDRI class serves as the main orchestrator for the system, initializing and managing the core components such as the router, scheduler, store, API, and connector. It provides methods to add components, start various services, and run the router.
- Attributes:
router_queue (
multiprocessing.Queue[Event]) -- The queue used for routing events between components.components (set[
edri.abstract.ManagerBase]) -- A set of manager components that are part of the system.store (
edri.utility.manager.Store) -- The store component for data storage.scheduler (
edri.utility.manager.scheduler.Scheduler) -- The scheduler component for scheduling tasks.api (
edri.api.listener.Listener) -- The API listener component.grpc (
edri.api.grpc.listener.GRPCListener) -- The gRPC API listener component.broker (
edri.api.broker.Broker) -- The broker component for handling middleware.connector (
edri.router.connector.Connector) -- The connector component for connecting to external services.router (
edri.router.Router) -- The router component that routes events.
- add_component(component: ManagerBase) None[source]¶
Adds a component to the EDRI system.
- Parameters:
component (
edri.abstract.ManagerBase) -- The component to be added.
- run() None[source]¶
Runs the router and all added components, handling graceful shutdown on SIGINT (KeyboardInterrupt) and SIGTERM.
SIGTERM is mapped to the same shutdown path, so process managers (systemd, Docker, Kubernetes) that stop the process with SIGTERM by default still get a clean shutdown.
- start_api(middlewares: list[Middleware] | None = None, json_encoder: Type[JSONEncoder] | None = None, jinja_extensions: set[Type['Extension']] | None = None) None[source]¶
Initializes and starts the API listener component with the provided middlewares.
- Parameters:
middlewares (list[Middleware] | None) -- A list of middleware instances, defaults to an empty list if None.
- start_broker(middlewares: list[Middleware] | None = None) None[source]¶
Initializes and starts the broker component with the provided middlewares.
- Parameters:
middlewares (list[Middleware] | None) -- A list of middleware instances.
- start_connector(router_id: UUID | None = None) None[source]¶
Initializes and starts the connector component with an optional router ID.
- Parameters:
router_id (UUID | None) -- The UUID of the router, defaults to None.
- start_grpc(host: str | None = None, port: int | None = None) None[source]¶
Initializes and starts the gRPC listener component, EDRI's gRPC API front end (per-event unary rpc plus one shared bidi-streaming rpc, schema generated at runtime from the same
@api-decorated events REST/WS/HTML already use). Runs as its own process, sharing the same Broker (started here if it hasn't been already) - can be started instead of, or alongside,start_api().- Parameters:
host -- Interface to bind, defaults to
EDRI_GRPC_HOST/localhost.port -- Port to bind, defaults to
EDRI_GRPC_PORT/50051.
- start_scheduler(jobs: list[Job] | Mapping[str, Job] | None = None) None[source]¶
Initializes and starts the scheduler component with optional jobs.
Jobs may be given as a list, where the scheduler generates an identifier for each job, or as a mapping, where the keys become the job identifiers usable with the scheduler's
UpdateandCancelevents.
- start_store(path: str | PathLike[str] | None = None, *, failure_policy: PersistenceFailurePolicy = PersistenceFailurePolicy.BUFFER, startup_timeout: float | None = 30.0) None[source]¶
Initializes and starts the Store, optionally restoring SQLite KV data.
path=Nonekeeps the Store entirely in memory. Persistent writes are asynchronous; BUFFER retries storage failures without blocking events. Persistent mode confirms child-process restoration before returning and raises RuntimeError on bootstrap failure or timeout.startup_timeout=Nonedisables the parent restoration deadline.