Skip to main content

Operations

The package contains plain invokable operation objects. They have no console dependency; bind them to the CLI, scheduler, or worker system used by the application.

Ensure a schema

Implement SchemaManagerInterface for the adapter and run:

use DomainFlow\EventSourcing\Operation\EnsureSchema;

$result = (new EnsureSchema($schemaManager))(dryRun: true);

The operation calls describeSchema(), and calls ensureSchema() only when dryRun is false.

Rebuild a projection

RebuildProjection resets a ProjectorInterface and replays the global event stream through CatchUpReader:

use DomainFlow\EventSourcing\Operation\RebuildProjection;

$result = (new RebuildProjection($eventStorage))($projector);

The result reports the replay count and the last safe stream position. Persist that position if the application also performs incremental catch-up.

Drain an outbox

Use DrainOutbox for a bounded worker invocation or a daemon loop. It supports pass and time limits, idle backoff, an injectable clock/sleeper, and a stop() method suitable for graceful signal handling. See Outbox delivery.

Time-dependent workers

SystemClock provides UTC time. FrozenClock can be advanced by seconds or a DateInterval, which lets tests cover timeout, retry, and grace-period behavior without sleeping.