Repository navigation
feat(engine): encapsulate label management in the Router SPI - #2404
Conversation
Router/RouterContext gain supplyLabelId/supplyLabel (and Router gains watchLabels) so a Router implementation owns label-id assignment and lookup consistency, instead of the engine's own internal.LabelManager singleton. EngineRouter/TestRouter absorb LabelManager's in-memory behavior; the Engine remains solely responsible for bootstrapping from and flushing to the on-disk labels file, independent of which Router implementation is active, so zilla dump keeps working unchanged.
…le-agnostic EngineRouter/TestRouter drop all knowledge of the labels file and the synchronized block used to serialize new-label registration. Id assignment is now a plain ConcurrentHashMap + AtomicInteger (mirroring MemoryStoreHandler's lock-free style) since computeIfAbsent's per-key atomicity is the only guarantee actually needed. Engine now owns bootstrapping too: it reads the labels file itself and replays each entry through the ordinary supplyLabelId call before registering the watchLabels flush listener, so a Router implementation never needs file-reading logic to reproduce prior label ids.
Router.watchLabels now takes ObjectIntBiConsumer<String> instead of BiConsumer<String, Integer>, mirroring the existing LongObjectBiConsumer pattern in this package. The primitive int overload lets EngineRouter/ TestRouter notify listeners on every new-label registration without boxing the label id.
binding-http and engine each carried their own copy of this helper functional interface. Helper functional interfaces of this shape already live in common-lang's util.function package (LongObjectBiFunction, LongObjectPredicate), so ObjectIntBiConsumer moves there too and both call sites reference the shared type instead of a local duplicate. engine now depends on common-lang (a dependency-free leaf module, no cycle risk) and re-exports it transitively so any Router implementation can reference ObjectIntBiConsumer; binding-http picks it up the same way it already does common-agrona, transitively through its existing engine dependency, with no pom.xml or module-info change needed there.
|
Not fixing it here since it's out of scope for this change. Proposed fix for a follow-up: regenerate Will keep watching and re-run once the base recovers. Generated by Claude Code |
common-lang reaches binding-tcp only transitively through engine, which is a provided-scope dependency here; the notice-plugin's includeScopes is compile-only, so provided-scope transitives are correctly excluded (engine and its own dependencies are attributed via the Docker image assembly, not per-binding). The checked-in NOTICE incorrectly listed common-lang since #2231 -- unrelated to this branch's own change of adding common-lang as a real (compile-scope) dependency of engine. Verified against the authoritative NOTICE.expected produced by a full reactor build (mirroring CI's ./mvnw clean package): the only diff was this one stray line.
Summary
LabelManagersingleton onto theRouter/RouterContextSPI (supplyLabelId,supplyLabel, andwatchLabelsonRouter), so aRouterimplementation owns label-id coordination — letting a future cluster-aware router supply its own consistency mechanism instead of relying on today's process-local, append-order assignment.EngineRouterabsorbsLabelManager's in-memory behavior (seeded from the existing<directory>/labelsfile);internal.LabelManageris deleted.TestRoutermirrors the same behavior sotype: testrouter configs keep working.labelsfile, independent of whichRouterimplementation is active, sozilla dump's independent reader of that file format is unaffected.Router.store(): Store—Routeris already the correct process-wide SPI extension point, and routing label consistency through a genericStorewould force an implicit mandatorystore-memoryruntime dependency for the default case and mismatch the CP guarantees a future cluster router needs.Test plan
./mvnw clean verify -pl runtime/engine— 226 unit tests + 208 integration tests pass, includingEngineITandRouterFactoryTest(extended with new coverage forsupplyLabelId/supplyLabelthrough bothRouterandRouterContext,watchLabelsnotification, and bootstrap-from-existing-file correctness)incubator/command-dump's independentlabelsfile reader has no coupling to the deletedinternal.LabelManagerclassGenerated by Claude Code