Files
task-stream/libs/api/shared/application
Josep Piguillem e14f445e6b fix(api): retry commands that clash with a concurrent write
Services run commands through a CommandRunner that runs one again (up to
5 times, waiting a little longer each time) when its aggregate changed
underneath, e.g. a saga writing to the same ticket. Each command loads its
aggregate fresh and stores its events in one transaction, so a
ConcurrencyError means nothing was stored and running it again is safe.
People no longer get a 409 for it, and the e2e suite stops flaking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 14:00:08 +02:00
..
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00

api-shared-application

Contrato del event store y reconstrucción de agregados.

  • Import: @task-stream/api/shared/application
  • Capa: application · Tags: scope:api-shared, type:application

Contenido

  • EventStore (puerto): persist y getEventsByStreamId.
  • AggregateRehydrator: carga los eventos de un stream y devuelve el agregado reconstruido, ya enlazado con el EventPublisher.
  • EventRecorder: guarda un evento en un stream que no es de ningún agregado propio (p. ej. un usuario de Pireon), en la siguiente posición, para que otros contextos reaccionen a él.
  • SharedModule.withInfrastructure(...): módulo global que expone el event store, el rehydrator y el recorder a todos los contextos.

Comandos

npx nx lint api-shared-application
npx nx test api-shared-application    # Jest

Reglas de dependencia entre capas: Arquitectura.