Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion docs/examples/onboarding-event-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Onboarding event store](../../site/assets/banners/onboarding-event-store.svg)

Submit a customer application, approve it, and reconstruct its state from PostgreSQL events. The example uses Jafly's `AggregateRoot` and `R2dbcEventStore`, with an application-owned `OnboardingEventService` connecting them.
Submit a customer application, approve it, and reconstruct its state from PostgreSQL events. The example uses Jafly's `AggregateRoot` and `R2dbcEventStoreImpl`, with an application-owned `OnboardingEventService` connecting them.

Run from the framework checkout after installing its libraries:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.fireflyframework.eventsourcing.config.EventSourcingProperties;
import org.fireflyframework.eventsourcing.domain.Event;
import org.fireflyframework.eventsourcing.store.ConcurrencyException;
import org.fireflyframework.eventsourcing.store.r2dbc.R2dbcEventStore;
import org.fireflyframework.eventsourcing.store.r2dbc.R2dbcEventStoreImpl;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
Expand All @@ -39,7 +39,7 @@ class OnboardingEventStoreTest {
.withInitScript("events.sql");

private DatabaseClient database;
private R2dbcEventStore store;
private R2dbcEventStoreImpl store;
private OnboardingEventService service;

@BeforeEach
Expand All @@ -53,7 +53,7 @@ void connectToPostgres() {
var mapper = new ObjectMapper().registerModule(new JavaTimeModule());
mapper.registerSubtypes(new NamedType(ApplicationSubmitted.class, "onboarding.application.submitted"),
new NamedType(ApplicationApproved.class, "onboarding.application.approved"));
store = new R2dbcEventStore(database, new R2dbcEntityTemplate(connectionFactory), mapper,
store = new R2dbcEventStoreImpl(database, new R2dbcEntityTemplate(connectionFactory), mapper,
new EventSourcingProperties(), manager, TransactionalOperator.create(manager), connectionFactory);
service = new OnboardingEventService(store);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/immutable-local-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This opt-in capability appends canonical kernel audit values and a permanent out

## Construct on the owning resource graph

The owner constructs one stable `OwnedLeaseConnectionFactory`, `DatabaseClient`, `R2dbcEntityTemplate` and `R2dbcTransactionManager`, verifies them with `BoundedR2dbcResources.verify`, and uses the existing `DefaultBoundedRootTransaction`. Pass those exact objects to `SpringDataTransactionalAuditAppender`, together with a mandatory genuine `AuditAppendAuthority` and the **same Clock and LongSupplier instances used for the original operation budget**. Do not wrap or replace a caller's client/template, converters or statement filters.
The owner constructs one stable `OwnedLeaseConnectionFactoryImpl`, `DatabaseClient`, `R2dbcEntityTemplate` and `R2dbcTransactionManager`, verifies them with `BoundedR2dbcResources.verify`, and uses the existing `DefaultBoundedRootTransactionImpl`. Pass those exact objects to `SpringDataTransactionalAuditAppenderImpl`, together with a mandatory genuine `AuditAppendAuthority` and the **same Clock and LongSupplier instances used for the original operation budget**. Do not wrap or replace a caller's client/template, converters or statement filters.

The appender's `append(scope, event)` must be composed into the owning root work publisher, before that publisher completes. It proves the private active invocation and exact RootTransactionScope/resource graph before admission, then uses the transaction-bound same connection. It never invokes a second root or generic joining TransactionalOperator. Ordinary ambient transactions, stale/foreign scopes and mismatched graphs refuse. Narrowing the genuine original scope preserves its identity.

Expand All @@ -14,7 +14,7 @@ The authority port must resolve the authenticated current actor, authorize the r

Every public `LocalAuditRepository` operation also requires the genuine RootTransactionScope and the same verified factory/client/template/manager graph; it cannot fall back to an ordinary ambient transaction. It exposes no inherited general CRUD API. Its mapped statement helpers are private.

`SpringDataLocalAuditRepository` uses the owning template's genuine mapping strategy/converter and StatementMapper for ordinary inserts and head CAS. Every insert/update must observe exactly one actual affected row. Zero, multiple and missing observations refuse. It stores every canonical kernel field, including separate Instant seconds/nanos, with no serializer-dependent JSON. Event uniqueness is `(resource_tenant_id,event_id)` across all streams in that tenant. The stream head CAS includes the whole scope, expected sequence and previous hash.
`SpringDataLocalAuditRepositoryImpl` uses the owning template's genuine mapping strategy/converter and StatementMapper for ordinary inserts and head CAS. Every insert/update must observe exactly one actual affected row. Zero, multiple and missing observations refuse. It stores every canonical kernel field, including separate Instant seconds/nanos, with no serializer-dependent JSON. Event uniqueness is `(resource_tenant_id,event_id)` across all streams in that tenant. The stream head CAS includes the whole scope, expected sequence and previous hash.

The immutable event and its immutable `AUDIT_EXPORT` intent are inserted in the same local transaction as the head and business work. The next append links the prior hash. Exact replay reads the original full event, verifies its canonical record hash and full permanent outbox, and returns the original record without changing its timestamp or sequence. Different content under the same event ID refuses. A duplicate database error propagates without reading or continuing in the aborted transaction. A mandatory append failure marks the genuine owner transaction rollback-only, so catching a logical append refusal cannot commit the business effect. Marking performs no SQL and never clears rollback-only.

Expand Down
Loading
Loading