Skip to main content

Module mock

Module mock 

Source
Expand description

Opt-in per-run activity mocking layered over the production dispatcher. Opt-in per-run activity mocking, layered over the production dispatcher.

The mock is a thin decorator on the real aion::ActivityDispatcher: a DevMockingDispatcher wraps the production [WorkerActivityDispatcher] and consults a shared ActivityMockRegistry before every dispatch. When a mock is registered for the dispatch’s (workflow_id, activity_name), the canned result is returned and the real worker is never contacted; otherwise the dispatch is delegated to the wrapped dispatcher unchanged.

This deliberately changes nothing in the engine (CN4): the engine still schedules, records, and replays the activity through its single Recorder exactly as in production — the recorded ActivityCompleted event for a mocked activity is indistinguishable from a real worker’s completion, so a replay or a server restart re-drives the run identically. The mock only short-circuits the transport-side worker round-trip for one run.

Mocks are keyed by the real [WorkflowId] the engine recorded, so they scope to exactly the run a developer triggered (each dev trigger starts a fresh workflow id) and never leak across runs.

Structs§

ActivityMockRegistry
Shared, mutable registry of per-run activity mocks consulted on every dispatch. Cloned freely; all clones share one table.
DevMockingDispatcher
Production dispatcher wrapped with per-run activity mocking.

Enums§

MockedActivity
A canned activity outcome installed for one workflow run.