Skip to content

refactor(sql,core): centralize journal persistence, dedupe SQL journal code - #957

Open
davidfrigolet wants to merge 1 commit into
masterfrom
refactor/centralize-journal-persistence
Open

davidfrigolet wants to merge 1 commit into
masterfrom
refactor/centralize-journal-persistence

Conversation

@davidfrigolet

Copy link
Copy Markdown
Contributor

Summary

Third and final part of centralizing Journal Event persistence across audit stores. Companion PRs:

⚠️ Blocked on the two PRs above being released. This branch currently points generalUtilVersion/sqlVersion at local -SNAPSHOT builds so it could be built and tested end-to-end; before merge, bump both to the real released versions once those PRs land.

What changed

  • SQL dialect code moved out: SqlJournalDialectHelper, JournalEventConstants, and the audit-column-name list that lived in community/flamingock-sql-auditstore are deleted here and now consumed from flamingock-sql-util, matching how the sibling SqlAuditorDialectHelper/SqlLockDialectHelper already work.
  • One default journal-store name instead of three: SQL, DynamoDB, and MongoDB sync audit stores each hardcoded their own "flamingockJournalEvents" literal in separate local constants classes. All three now read CommunityPersistenceConstants.DEFAULT_JOURNAL_STORE_NAME; the two now-redundant local constant classes are deleted.
  • Centralized per-stage journal init: JournalEventSequencerFactory (core) gained initializeForStage(stageId, autoCreate) — checks the journal-events feature flag, initializes the journal store, and returns the stage's sequencer in one call. SQL/DynamoDB/MongoDB stores' getPersistenceFactory() all delegate to it instead of each hand-rolling the same three steps slightly differently.
  • Bug fix as part of the centralization: MongoDBSyncAuditStore was never actually calling journalEventStore.initialize() per stage — the method was protected in a different package (...sync.internal) than the store itself (...sync), so the call was inaccessible and silently never happened. It's now public, part of the JournalEventStore interface contract, and wired through the shared init path along with the other two stores.

Not included — separate follow-up work

feat/couchbase-journal-events and feat/mongodb-reactive-journal-events were rebased onto master (both predated the SQL journal refactor already on master and would've conflicted otherwise) and compile clean, but are not wired into this centralization. Once this PR merges, CouchbaseAuditStore and MongoDBReactiveAuditStore still need:

  • the same CommunityPersistenceConstants.DEFAULT_JOURNAL_STORE_NAME swap (MongoDBReactiveAuditStore currently uses the now-deleted JournalEventPersistenceConstants from mongodb-util and will fail to compile once rebased on top of this branch)
  • wiring to JournalEventSequencerFactory.initializeForStage(...) the same way Sql/DynamoDB/MongoSync now are

Test plan

  • ./gradlew clean build — full repo, green
  • Targeted module tests (core, sql-auditstore incl. full dialect/testcontainers matrix, dynamodb-auditstore, mongodb-sync-auditstore, dynamodb-util, mongodb-util) — all pass
  • Bump generalUtilVersion/sqlVersion to released versions once the companion PRs are merged and released
  • Wire Couchbase/MongoReactive journal stores in a follow-up PR

…l code

Extracts SQL-specific Journal Event DDL/DML generation into the sibling
flamingock-sql-util module, deletes the "flamingockJournalEvents" literal
duplicated three times (SQL, DynamoDB, MongoDB stores) in favor of the new
CommunityPersistenceConstants.DEFAULT_JOURNAL_STORE_NAME, and centralizes
the per-stage journal initialization each community audit store was
reimplementing.

- SqlAuditStore/DynamoDBAuditStore/MongoDBSyncAuditStore no longer carry
  local copies of SqlJournalDialectHelper/JournalEventConstants or the
  default journal-store-name literal; they consume the shared versions
  from flamingock-sql-util and flamingock-general-util instead
- JournalEventSequencerFactory (core) gains initializeForStage(stageId,
  autoCreate): feature-flag-gates, initializes the journal store, and
  returns the stage sequencer in one call, replacing the near-duplicated
  three-way copy of this logic
- JournalEventStore.initialize(boolean) is now part of the interface
  contract rather than an implementation-specific method
- fixes MongoDBSyncAuditStore never calling journalEventStore.initialize()
  per stage: its initialize method was protected in a different package
  and unreachable from the store, so the call was silently skipped; it is
  now public and wired through the new centralized init path
- bumps generalUtilVersion/sqlVersion to the versions carrying the moved
  code (pending release of the two companion PRs below)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant