Skip to content

v0.22.0 — SQL idempotency, partitioned/append-only outbox (PG+MySQL), scaffold aggregate+outbox

Choose a tag to compare

@daniel-garcia daniel-garcia released this 27 Jun 09:16
a283d9d

Three follow-on items on the aggregate/events subsystem, each implemented → hardened → shipped.

1. SQL-backed EntIdempotencyStore (#84)

Closes the documented ent exactly-once gap: the ent dispatch path used the in-memory idempotency store (marker not in the handler tx → orphan-marker window). Adds EntIdempotencyStore (the ent twin of gormtx.GormIdempotencyStore) — Record inserts the marker through the handler's *ent.Tx, unique conflict → events.ErrAlreadyApplied. Exactly-once verified on real Postgres under -race.

2. Append-only partitioned outbox + drop-partition retention, Postgres AND MySQL (#85)

Reworks the outbox per directive — no read+delete churn:

  • Append-only: a delivered event costs one claim-lease + one idempotent delivered_time mark over its whole life, then is never re-claimed or DELETEd (hardening caught + fixed a make-or-break bug where delivered events were re-claimed every poll, moving churn from DELETE to repeated UPDATEs).
  • Drop-partition retention: declarative RANGE partitioning on created_time (PG) / TO_DAYS RANGE (MySQL); retention = DROP PARTITION (O(1) DDL, proven load-bearing via partition-count assertions, not row-delete). RunRetention helper; the service owns the scheduler.
  • OutboxCDCConsumer seam (interface + docs only) so an integrator can plug logical-replication/Debezium (WAL) without the SDK shipping a heavy CDC engine — "WAL if possible, else partitions," with partitioning built into the pattern.
  • Validated on real Postgres and MySQL 8 (testcontainers, -race); CI guards both didn't silently skip.

3. Scaffold aggregate + outbox out of the box (#86)

devedge-sdk new service --aggregate generates a service that wires TxRunner + AggregateRepository + outbox (both ent and gorm) with the member resource boundary-gated (no direct member writes). Non-aggregate scaffold output is byte-identical to before. Proven by integration tests that drive real make generate/build/test.

Throughout

Clean core preserved (no ORM/driver/CDC/broker dep in persistence/authz/grpcauthz/events; engine deps confined to the gormtx/entrepo adapters and testdata go.mods). CI green on main. Known follow-up: a latent protoc-gen-ent multi-word has_many edge-accessor bug (sidestepped, not yet fixed).