Repository navigation
refactor(binding-kafka): replace KafkaPipeline with ModelEnvelope-backed extraction - #2458
Merged
Merged
Conversation
…ked extraction KafkaPipeline provided a bespoke whole-message lane vocabulary (SWITCH_KEY/ SWITCH_VALUE/SWITCH_HEADERS/FIELD) so extract-key/extract-headers topic transforms could route a matched field to a different destination. This predates ModelEnvelope (#1689/#2455), which already lets a composed ModelTransform read/write named, out-of-value metadata directly and is already used by the produce and client-fetch paths without any lane vocabulary at all. Extends the same envelope mechanism to the key's own model via a reserved ":key" pseudo-name (HTTP/2-pseudo-header style), letting extract-key resolve the same way extract-headers already does through KafkaCacheHeadersEnvelope/ KafkaCacheTrailerEnvelope. KafkaExtractTransform is rewritten as a plain ModelTransform that calls envelope.set() on a path match; KafkaCacheServerFetchFactory composes it directly per extract-key/extract-headers config entry, replacing KafkaPipeline's lane-switch dispatch and KafkaCachePartition's KafkaEntrySink single-slot key buffering and heap-resident trailers builder. KafkaCachePartition's populate-path writeEntryStart/writeEntryFinish now take KafkaCacheModel transformKey/transformValue directly (matching the produce path's existing shape) instead of a KafkaPipeline, and reuse a claimed block in the log file for header collection during the value drive -- mirroring the produce path's claim-per-message design -- rather than a heap-resident builder reused across every fetched message on a partition. A new cache.server.trailers.size.max config bound sizes this claim, gated on whether the topic actually configures a value model. KafkaPipeline, KafkaEvent, KafkaSink, KafkaSource, KafkaController, and KafkaTransform are removed entirely along with their tests and benchmarks, which exercised the deleted lane-switch mechanism directly. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CzxN4tJLhiHQ8ikNeuN8WS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
KafkaPipelinesits aboveModelPipeline/KafkaCacheModeland provides a bespoke whole-message lane vocabulary (KafkaEvent:SWITCH_KEY/SWITCH_VALUE/SWITCH_HEADERS/FIELD, plusKafkaSink/KafkaSource/KafkaController/KafkaTransform) so a topic'stransforms: extract-key/extract-headersconfig can promote a field observed mid-traversal into the key or a header. It predatesModelEnvelope, the engine SPI that already lets a composedModelTransformread/write named, out-of-value metadata directly — already used by the produce path (KafkaCacheTrailerEnvelope) and the client-fetch path (KafkaCacheHeadersEnvelope) to do exactly whatextract-headersdoes, with no lane vocabulary at all.This PR closes that gap for the key side too, via a reserved
:keypseudo-name (colon-prefixed, HTTP/2-pseudo-header style — deliberately notzilla:key, which is a real, wire-materialized header elsewhere), lettingextract-keyresolve the same wayextract-headersalready does. With both extraction paths expressible as a plain, composedModelTransformwriting into an envelope,KafkaPipelineand its supporting lane vocabulary (KafkaEvent,KafkaSink,KafkaSource,KafkaController,KafkaTransform) have no remaining reason to exist and are removed.Changes
KafkaExtractTransformrewritten as a plainModelTransform: on a field-path match it callsenvelope.set(name, value), nothing else. Multipleextract-headersentries compose the same way anyModelTransformchain already does, viaandThen.KafkaCacheKeyEnvelope(new): a minimal single-valueModelEnvelopefor the key's own model, recognizing only the reserved:keyname — the key-side counterpart to the existingKafkaCacheHeadersEnvelope/KafkaCacheTrailerEnvelope.KafkaCacheModel.writer(...)widened with aModelEnvelopeparameter, matching the shapeencoder/readeralready had.KafkaCacheServerFetchFactorycomposesKafkaExtractTransformdirectly perextract-key/extract-headersconfig entry, replacingKafkaPipeline's lane-switch dispatch.KafkaCachePartition's populate-pathwriteEntryStart/writeEntryFinishnow takeKafkaCacheModel transformKey/transformValuedirectly (matching the produce path's existing shape) instead of aKafkaPipeline, and reuse a claimed block in the log file for header collection during the value drive — mirroring the produce path's claim-per-message design — in place of a heap-resident builder reused across every fetched message on a partition.KafkaEntrySink's single-slot key buffering is replaced by an in-place padded-key overwrite sourced from the key's envelope, aborting the entry (rather than corrupting adjacent bytes) if an override doesn't fit within the key's own reserved padding.cache.server.trailers.size.maxconfig bound (mirrors the existingcache.client.trailers.size.max) sizes the populate-path claim, applied only when the topic actually configures a value model.KafkaPipeline,KafkaEvent,KafkaSink,KafkaSource,KafkaController,KafkaTransformremoved entirely, along with their tests and JMH benchmarks (which exercised the deleted lane-switch mechanism directly).The
transforms: extract-key/extract-headersYAML config surface is unchanged — only the internal implementation changes. Existingextract-key/extract-headersk3po coverage (CacheFetchIT#shouldReceiveMessagesWithExtractedKey,#shouldReceiveMessagesWithExtractedHeaderFilter) passes unmodified, plus new unit coverage for sequential-entry envelope reuse and the key-override / header-collection overflow paths.Test plan
./mvnw clean verify -pl runtime/binding-kafka— unit tests, all k3po ITs, checkstyle, license, JaCoCo all greenextract-key/extract-headersk3po scenarios pass unmodifiedKafkaExtractTransformTest,KafkaCacheKeyEnvelopeTest, plusKafkaCachePartitionTestcases for sequential-entry envelope reuse, null-key-then-real-key sequencing, key-override-overflow abort, and header-collection-claim overflow abortGenerated by Claude Code