You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
binding-kafka: cache_client and cache_server should pass raw API request streams through to the client binding #3183
Raw Kafka API streams (KIND_API_REQUEST, KafkaApiRequestBeginEx carrying the API key, version, client id and tags, with the request and response frames as stream data) are registered only by the kafka client binding (KafkaClientFactory and KafkaClientApiFactory). KafkaCacheClientFactory and KafkaCacheServerFactory register meta, describe, group, consumer, offset commit, offset fetch, init producer, fetch, produce, merged and bootstrap streams, and no API request stream (read on develop at 5556779). A raw API request stream opened toward a cache_client binding is therefore rejected, and an application that reaches Kafka through the standard topology (cache_client -> cache_server -> client) cannot use the raw API streams that only the client binding serves.
Expected
cache_client accepts a KIND_API_REQUEST stream and passes it through to its exit, and cache_server passes it on to its exit (the client binding), without caching, filtering or interpreting the frames, so the stream behaves as if it had been opened on the client binding directly, including the version negotiation (the ApiVersions challenge and the flush that selects a version) and the response stream.
Streams of every other kind are unaffected.
How the begin, window, data, flush, challenge, end, abort and reset frames are forwarded follows how the cache bindings already forward the streams they pass through unchanged; where they do not forward any stream unchanged, the design below says what pattern is mirrored.
Design first
Before implementing, post a short design on this issue: which existing pass-through or proxy stream in cache_client and cache_server is mirrored (if none exists, say so and ask before inventing one), how route resolution picks the exit for an API stream (the binding's exit or a route), how flow control and the challenge and flush frames are relayed in both directions, and the error and reset mapping. The pattern to mirror must be an existing implementation in the same module.
Test plan (test-first)
Paired client.rpt and server.rpt scripts under specs/binding-kafka.spec that run an API request stream (the plain and the version-negotiated variants, as the existing client binding scripts do) through a cache_client and a cache_server to a scripted peer, a spec-level IT per protocol side, and the runtime ITs in binding-kafka for both cache bindings. The first commit contains the failing scripts.
KafkaClientFactory registers KIND_API_REQUEST -> KafkaClientApiFactory. Its newStream resolves the route with binding.resolve(authorization, null).
The stream is opened with a KafkaApiRequestBeginEx (api, version, length, clientId). The reply BEGIN carries KafkaApiResponseBeginEx.
Version negotiation:
The client binding writes a WINDOW and then a CHALLENGE on the initial stream id. The challenge carries KafkaChallengeEx.apiChallenge with the broker's min and max versions. It comes from the ApiVersions exchange.
The initiator answers with a FLUSH on the initial stream id. The flush carries KafkaFlushEx.apiFlush with the chosen version.
The client binding then encodes the request header and the stream continues.
A reply FLUSH after the response body also exists in the scripts.
KafkaCacheClientFactory and KafkaCacheServerFactory have no KIND_API_REQUEST entry, so newStream returns null and the stream is rejected.
Pattern to mirror
KafkaCacheInitProducerIdFactory is an existing pass-through in the same module. One class is registered in both cache factories, and each creates its own instance.
newStream resolves the exit with binding.resolve(authorization, null). It returns null (reject) if there is no route.
It pairs an App object (the caller side) with a Net object (the exit side).
It relays BEGIN, DATA, END, ABORT, WINDOW and RESET in both directions, without interpreting the frames.
KafkaCacheGroupFactory and KafkaCacheOffsetFetchFactory show how FLUSH is relayed: a FlushFW case in onXxxMessage, a doFlush builder, and a doXxxFlush on the paired object.
Gap: no cache factory relays CHALLENGE (ChallengeFW is referenced only in KafkaClientApiFactory). The relay is the same shape as FLUSH, with the frame sent toward the initiator on the initial stream id. I plan to mirror the FLUSH relay for it. If that is not acceptable, say so before implementation.
Design
New class KafkaCacheApiFactory, registered for KIND_API_REQUEST in both KafkaCacheClientFactory and KafkaCacheServerFactory (one line each, as for KIND_INIT_PRODUCER_ID). No other kind is touched.
Exit selection.binding.resolve(authorization, null): the binding's exit, or the first authorized route with no topic condition, exactly as for KafkaCacheInitProducerIdFactory. A stream with no resolved exit is rejected. There is no change to binding configuration, route matching or the JSON schema.
Relay, caller to exit (initial direction):
BEGIN is relayed with the extension bytes copied as-is.
DATA is relayed with the same flags, reserved, budgetId and payload.
END and ABORT are relayed.
FLUSH is relayed with its extension, which carries apiFlush.
Relay, exit to caller:
Reply BEGIN, DATA, END and ABORT are relayed.
The initial-stream WINDOW and RESET from the exit are relayed to the caller.
CHALLENGE is relayed to the caller on the initial stream id.
Reply FLUSH is relayed on the reply stream id.
The caller's reply WINDOW and RESET are relayed to the exit.
Flow control.
Each direction keeps its own seq, ack and max on both the App and Net sides.
Credit from the exit's WINDOW is passed to the caller (acknowledge, maximum, budget and padding) and DATA is forwarded 1:1, as in KafkaCacheInitProducerIdFactory. No buffering, no slot, no margin.
CHALLENGE and FLUSH carry no credit.
Version negotiation. It passes through untouched. The exit's CHALLENGE (min/max versions) reaches the caller, and the caller's FLUSH (chosen version) reaches the exit. The cache layer does not interpret the versions.
Error and reset mapping.
An ABORT or RESET on either side is relayed to the peer.
RESET extensions (for example KafkaResetEx with an error code) are copied as-is.
If either side closes, the other side is cleaned up, as KafkaCacheInitProducerIdFactory does.
Test plan (test-first)
Specs under specs/binding-kafka.spec, as paired client.rpt and server.rpt:
plain API request: application/api/create.topics.v7-style scripts for the pass-through case;
version-negotiated variant: challenge, then flush, then request and response, modelled on application/api/api.challenge.negotiate;
an unsupported-version reset case, to check RESET and abort mapping.
Spec-level ITs: methods in the existing application ITs, ApplicationIT style for the API scripts. One class per protocol side, one method per scenario.
Runtime ITs: methods in the existing CacheXxxIT classes, using cache.yaml, for both cache_client and cache_server, with a scripted peer at the exit.
Order: the first commit holds the failing scripts and IT methods only. I will confirm they fail because the stream is rejected (newStream returns null), then implement.
Verification:clean verify with checkstyle and license checks on and the build cache skipped, for specs/binding-kafka.spec and runtime/binding-kafka.
Activity
jfallows commentedon Nov 13, 2026
Design: pass raw API request streams through
cache_clientandcache_serverRead on
developat 5556779.How a raw API stream is served today
KafkaClientFactoryregistersKIND_API_REQUEST->KafkaClientApiFactory. ItsnewStreamresolves the route withbinding.resolve(authorization, null).KafkaApiRequestBeginEx(api, version, length, clientId). The reply BEGIN carriesKafkaApiResponseBeginEx.KafkaChallengeEx.apiChallengewith the broker's min and max versions. It comes from the ApiVersions exchange.KafkaFlushEx.apiFlushwith the chosen version.KafkaCacheClientFactoryandKafkaCacheServerFactoryhave noKIND_API_REQUESTentry, sonewStreamreturns null and the stream is rejected.Pattern to mirror
KafkaCacheInitProducerIdFactoryis an existing pass-through in the same module. One class is registered in both cache factories, and each creates its own instance.newStreamresolves the exit withbinding.resolve(authorization, null). It returns null (reject) if there is no route.Appobject (the caller side) with aNetobject (the exit side).KafkaCacheGroupFactoryandKafkaCacheOffsetFetchFactoryshow how FLUSH is relayed: aFlushFWcase inonXxxMessage, adoFlushbuilder, and adoXxxFlushon the paired object.ChallengeFWis referenced only inKafkaClientApiFactory). The relay is the same shape as FLUSH, with the frame sent toward the initiator on the initial stream id. I plan to mirror the FLUSH relay for it. If that is not acceptable, say so before implementation.Design
New class
KafkaCacheApiFactory, registered forKIND_API_REQUESTin bothKafkaCacheClientFactoryandKafkaCacheServerFactory(one line each, as forKIND_INIT_PRODUCER_ID). No other kind is touched.binding.resolve(authorization, null): the binding'sexit, or the first authorized route with no topic condition, exactly as forKafkaCacheInitProducerIdFactory. A stream with no resolved exit is rejected. There is no change to binding configuration, route matching or the JSON schema.apiFlush.AppandNetsides.KafkaCacheInitProducerIdFactory. No buffering, no slot, no margin.KafkaResetExwith an error code) are copied as-is.KafkaCacheInitProducerIdFactorydoes.Test plan (test-first)
specs/binding-kafka.spec, as pairedclient.rptandserver.rpt:application/api/create.topics.v7-style scripts for the pass-through case;application/api/api.challenge.negotiate;ApplicationITstyle for the API scripts. One class per protocol side, one method per scenario.CacheXxxITclasses, usingcache.yaml, for bothcache_clientandcache_server, with a scripted peer at the exit.newStreamreturns null), then implement.clean verifywith checkstyle and license checks on and the build cache skipped, forspecs/binding-kafka.specandruntime/binding-kafka.apiChallengeandapiFlushshapes.Generated by Claude Code
feat(binding-kafka): pass raw api request streams through the cache b…
feat(binding-kafka): pass raw api request streams through the cache b…
feat(binding-kafka): pass raw api request streams through the cache b…