Skip to content

1.5.0

Latest

Choose a tag to compare

@gradyzhuo gradyzhuo released this 17 Nov 09:29
· 1 commit to main since this release

1.5 has three parts:

  • withUnitOfWork. Saves from several usecases commit together, or not at all.
  • swift-kurrentdb 3.0. The minimum is now 3.0.0.
  • Fixes for link streams and the generator. A read skips links whose event is gone, and an unknown key in projection-model.yaml fails the build.

Upgrading from 1.4? Read the 1.4 → 1.5 migration guide. Several behaviour changes are not flagged by the compiler. The guide also has a machine-readable manifest for AI agents. MIGRATION.md has the same steps as text.

Highlights

withUnitOfWork

  • Every repository.save inside withUnitOfWork { work in … } is collected and written when the block returns. A block that throws writes nothing.
  • work.onCommitted { … } runs hooks after a successful commit; use it to publish events.
  • Existing usecases, repositories and generated code take part unchanged.
  • KurrentStorageCoordinator takes part. InMemoryEventStore and PersistentEventStore do not: a save to them inside a block is refused.
  • A commit of two or more streams uses KurrentDB's AppendRecords and needs KurrentDB 26.1 or later.
  • Writes commit together only through the same KurrentDBClient instance.

See Compose Usecases with withUnitOfWork in the README.

swift-kurrentdb 3.0

  • Reads are lazy: a find or fetchEvents whose task is cancelled midway throws CancellationError.
  • swift-kurrentdb has its own CustomMetadata. In a file that imports KurrentDB, write EventSourcing.CustomMetadata.

Link streams

LiveEventStoreClient.readStream skips a link whose event is gone (source stream deleted, tombstoned, truncated or scavenged) and logs a warning. Before, one such link failed the whole read, so a linkTo read model stream could not be read.

Generator

An unknown key in projection-model.yaml, or a file that does not decode, fails the build. The error names the model, the key and the known keys. Before, the key was ignored and its events were missing from the generated code.

Projector

EventSourcingProjector.execute(input:) logs a warning when it returns nil because buildReadModel or apply threw.

Source-breaking

  • EventStoreClient.identity has no default: custom conformances and wrappers must implement it, and forward appendAtomically(_:).
  • EventStoreClientError has new cases: consistencyViolations, atomicAppendUnsupported.
  • A direct swift-kurrentdb requirement must be 3.0.0 or later.
  • A bare CustomMetadata next to import KurrentDB is ambiguous.
  • An unknown key in projection-model.yaml fails the build.