Skip to content

feat(couchbase): add journal event persistence - #949

Open
davidfrigolet wants to merge 3 commits into
masterfrom
feat/couchbase-journal-events
Open

feat(couchbase): add journal event persistence#949
davidfrigolet wants to merge 3 commits into
masterfrom
feat/couchbase-journal-events

Conversation

@davidfrigolet

Copy link
Copy Markdown
Contributor

feat(couchbase): add journal event persistence

@dieppa dieppa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM , but I would @osantana85 to take a look. He is more familiar with couchebase

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds feature-flagged Couchbase journal event persistence with transactional audit synchronization and integration coverage.

Changes:

  • Added journal mapping, constants, indexing, storage, and acknowledgement support.
  • Integrated journal writes with Couchbase transactions and stage sequencing.
  • Added feature-flag, rollback, and end-to-end tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Summary Review notes
utils/couchbase-util/src/main/java/io/flamingock/internal/common/couchbase/journal/JournalEventPersistenceConstants.java Defines journal collection defaults.
utils/couchbase-util/src/main/java/io/flamingock/internal/common/couchbase/journal/JournalEventFieldConstants.java Defines persisted journal fields.
utils/couchbase-util/src/main/java/io/flamingock/internal/common/couchbase/CouchbaseJournalEventMapper.java Maps journal events to Couchbase documents.
utils/couchbase-util/src/main/java/io/flamingock/internal/common/couchbase/CouchbaseCollectionHelper.java Adds secondary-index creation support.
core/target-systems/flamingock-couchbase-externalsystem-api/src/main/java/io/flamingock/externalsystem/couchbase/api/CouchbaseExternalSystem.java Exposes transactional Couchbase behavior. Critical, 1 vote: New abstract API breaks existing implementations; preserve compatibility or explicitly version the breaking change.
core/target-systems/flamingock-couchbase-externalsystem-api/build.gradle.kts Adds the transactional API dependency.
community/flamingock-couchbase-auditstore/src/test/java/io/flamingock/store/couchbase/internal/CouchbaseAuditPersistenceJournalTest.java Tests transactional persistence and rollback.
community/flamingock-couchbase-auditstore/src/test/java/io/flamingock/store/couchbase/CouchbaseJournalFeatureFlagE2ETest.java Tests feature-flagged end-to-end behavior.
community/flamingock-couchbase-auditstore/src/main/java/io/flamingock/store/couchbase/internal/CouchbaseJournalEventStore.java Implements journal storage and acknowledgement. Moderate, 4 votes: Acknowledgement updates should exclude already acknowledged events to avoid overcounting retries.
community/flamingock-couchbase-auditstore/src/main/java/io/flamingock/store/couchbase/internal/CouchbaseAuditPersistence.java Coordinates atomic audit and journal writes.
community/flamingock-couchbase-auditstore/src/main/java/io/flamingock/store/couchbase/internal/CouchbaseAuditor.java Supports append and current-state persistence.
community/flamingock-couchbase-auditstore/src/main/java/io/flamingock/store/couchbase/CouchbaseAuditStore.java Wires journal-aware persistence. Critical, 1 vote: Deprecated getPersistence() now throws unconditionally, breaking existing callers when journaling is disabled.
Suppressed comments (1)

community/flamingock-couchbase-auditstore/src/main/java/io/flamingock/store/couchbase/internal/CouchbaseJournalEventStore.java:212

  • Couchbase KV document keys are limited to 250 UTF-8 bytes, but JournalEvent permits any non-blank stream ID and this concatenation has no size check. A sufficiently long stage/stream ID will therefore make a journal-enabled audit write fail with a key-length error and roll back its audit entry. Validate the encoded key length (with a useful configuration error) or use a bounded deterministic key representation before inserting.
    private static String toKey(String streamId, long streamSequence) {
        return KEY_PREFIX + "::" + streamId + "::" + streamSequence;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +159 to +160
public CommunityAuditPersistence getPersistence() {
throw new UnsupportedOperationException("getPersistence shouldn't be called at Couchbase audit store; use getPersistenceFactory(stageId)");
Comment on lines +202 to +204
String query = String.format(
"UPDATE `%s`.`%s`.`%s` SET %s = true WHERE %s IN $eventIds RETURNING META().id",
collection.bucketName(), collection.scopeName(), collection.name(), KEY_ACKNOWLEDGED, KEY_EVENT_ID);
import io.flamingock.internal.common.core.transaction.TransactionalExternalSystem;

public interface CouchbaseExternalSystem extends ExternalSystem {
public interface CouchbaseExternalSystem extends TransactionalExternalSystem {
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.

4 participants