Skip to content

public/service: expose collapsed count helpers for plugin developers#396

Open
twmb wants to merge 3 commits intomainfrom
connect-1877
Open

public/service: expose collapsed count helpers for plugin developers#396
twmb wants to merge 3 commits intomainfrom
connect-1877

Conversation

@twmb
Copy link
Contributor

@twmb twmb commented Mar 17, 2026

Summary

  • Adds Message.WithCollapsedCount(count int) method to indicate a message is the result of collapsing multiple messages into one
  • Adds MessageBatch.CollapsedCount() method to get the total collapsed count across a batch
  • These wrap the internal batch.CtxWithCollapsedCount / batch.CtxCollapsedCount functions, enabling plugin developers to properly set collapsed counts for accurate output_sent / output_batch_sent metrics when implementing batch-collapsing processors (like archive)
  • Count is accumulative: calling WithCollapsedCount(3) then WithCollapsedCount(2) yields 4 (base + count - 1 to avoid double-counting)

Test plan

  • Unit test for WithCollapsedCount and CollapsedCount covering default, set, accumulation, and multi-message batch
  • All existing public/service tests pass

Closes redpanda-data/connect#1877

🤖 Generated with Claude Code

@claude
Copy link

claude bot commented Mar 19, 2026

Commits
LGTM

Review
Clean public API wrappers around existing internal batch.CtxWithCollapsedCount / batch.CtxCollapsedCount. The implementation mirrors the internal MessageCollapsedCount pattern and tests cover default, accumulation, and multi-message batch scenarios.

LGTM

@mmatczuk
Copy link
Contributor

API change @Jeffail PTAL

twmb and others added 3 commits March 19, 2026 09:10
Adds Message.WithCollapsedCount and MessageBatch.CollapsedCount methods
to the public service package so that plugin developers can properly set
collapsed counts for output metrics when implementing batch-collapsing
processors like archive.

Closes redpanda-data/connect#1877

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link

claude bot commented Mar 19, 2026

Commits
LGTM

Review
Adds WithCollapsedCount and CollapsedCount as thin public wrappers over the internal batch.CtxWithCollapsedCount/batch.CtxCollapsedCount functions. The delegation is correct, accumulation semantics match the internal implementation, and the test covers default, set, accumulation, and multi-message batch scenarios.

LGTM

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.

Proposal: expose WithCollapsedCount to the public package

2 participants