Skip to content

refactor(api): ConsumerConfig — collapse the 5-site consumer-wide settings mirror - #293

Merged
eschizoid merged 1 commit into
mainfrom
refactor/consumer-config
Jul 31, 2026
Merged

refactor(api): ConsumerConfig — collapse the 5-site consumer-wide settings mirror#293
eschizoid merged 1 commit into
mainfrom
refactor/consumer-config

Conversation

@eschizoid

Copy link
Copy Markdown
Owner

Architecture-pass item #6. The ~12 consumer-wide settings (retry, backpressure, mode, key cap, metrics, error handler, DLQ, poll timeout, tracer, circuit breaker) were mirrored across five sites between DefaultStream and MultiBuilder — a drift class that already caused one real bug (batch routes silently dropped tracer/CB).

Now: one package-private ConsumerConfig record owns the list — applyTo(builder) is THE apply chain (all three build paths call it), and CONSUMER_WIDE_SETTINGS descriptors drive the per-route rejection guard (was 10 hand-written blocks), preserving the existing error-message shapes. Adding a setting is now: component + one applyTo line + one descriptor + the thin public delegates.

No public API change; Stream immutability semantics intact (withers still return new records). Verified: :lib:kpipe-api:test 84/84 (incl. Docker integration suites), :lib:kpipe-consumer:test 430/430, kpipe-test + demo compile. Equivalence spot-check: the unconditional withKeyOrderedMaxKeys(default) cannot trigger the builder's misconfig WARNING (value-based guard, default==default).

The ~12 consumer-wide settings (retry, backpressure, processing mode,
key-ordered cap, metrics, error handler, dead-letter topic, poll timeout,
tracer, circuit breaker) were mirrored across five sites: DefaultStream's
record components + Mut + withers, its applyCommonConsumerConfig chain,
MultiBuilder's fields + withers, MultiBuilder.start()'s re-implemented
if-not-null chain, and rejectPerRouteConsumerWideSettings' ten hand-written
checks. That drift class already bit once — the batch path silently dropped
tracer and circuit breaker because one mirror lagged the others.

ConsumerConfig (package-private, kpipe-api) now owns the list:

- An immutable record with the 12 components and a Mut funnel, mirroring
  the DefaultStream mutate pattern.
- applyTo(KPipeConsumerBuilder) is THE apply chain. DefaultSink,
  DefaultBatchSink, and MultiBuilder.start() all call it, so the three
  build paths cannot diverge. Folding processingMode/keyOrderedMaxKeys
  into the chain is behavior-preserving: builder setters are plain field
  writes (all cross-setting derivation happens in its build()), and the
  facade defaults equal the builder defaults.
- CONSUMER_WIDE_SETTINGS descriptors (name + is-set predicate + rejection
  message) drive the per-route guard; the messages still point users at
  the MultiBuilder mirror method by name, and the reporting order is
  unchanged.

DefaultStream keeps its public immutability contract — the consumer-wide
withers now funnel through mutateConfig, still returning a new stream per
call. MultiBuilder collapses twelve fields to one ConsumerConfig; its
withers keep their exact validation messages. Adding a setting is now: one
component on ConsumerConfig, one applyTo line, one descriptor, and the
thin Stream/MultiBuilder delegates.

Only KPipeFacadeBuildTest reached the old record accessors; it now reads
through stream.consumerConfig().
@eschizoid
eschizoid merged commit 671e7fd into main Jul 31, 2026
2 checks passed
@eschizoid
eschizoid deleted the refactor/consumer-config branch July 31, 2026 05:44
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.14563% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.56%. Comparing base (5c2a392) to head (b9943bc).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...java/io/github/eschizoid/kpipe/ConsumerConfig.java 90.56% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #293      +/-   ##
============================================
+ Coverage     79.26%   79.56%   +0.29%     
- Complexity     1032     1061      +29     
============================================
  Files            83       84       +1     
  Lines          3560     3572      +12     
  Branches        457      441      -16     
============================================
+ Hits           2822     2842      +20     
  Misses          546      546              
+ Partials        192      184       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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