mochengqian opened a new pull request, #963:
URL: https://github.com/apache/dubbo-go-pixiu/pull/963

   ## What
   
   Make LLM proxy cooldown store ownership explicit, resolving #939.
   
   Previously the cooldown store was a package-level `sharedCooldownStore` 
reached through a multi-level fallback in both `FilterFactory.cooldownStore()` 
and `RequestExecutor.cooldownStore()`. Ownership was fuzzy and it made test 
isolation / future multi-manager behavior harder.
   
   Now the proxy `Plugin` — registered once at init and living for the whole 
process in the filter registry — lazily owns a single cooldown store 
(`sync.Once`) and injects it into every `FilterFactory` it creates. The factory 
passes it to each `Filter`, and the `RequestExecutor` always receives a non-nil 
store from construction, so the production request path has no fallback 
resolver.
   
   ## Why the Plugin, not ClusterManager
   
   The issue's preferred direction was for `ClusterManager` to own the store. 
That isn't viable without restructuring: `pkg/server` does not import 
`pkg/filter/llm/proxy` (the dependency runs the other way), so `ClusterManager` 
cannot hold the proxy-private `cooldownStore` type without an import cycle or 
moving the type out and burdening the generic cluster manager with LLM-specific 
state. The `Plugin` is the "another clearly owned process-level runtime object" 
the issue allows, and it keeps cooldown — an LLM concern — inside the LLM 
package while preserving the survives-reload property the old global provided.
   
   ## Changes
   
   - `Plugin` gains `sync.Once` + `*cooldownStore` and a lazy `cooldownStore()` 
accessor.
   - `CreateFilterFactory` injects the store; `PrepareFilterChain` and the 
executor read the explicit field.
   - Removed `sharedCooldownStore`, `FilterFactory.cooldownStore()`, and 
`RequestExecutor.cooldownStore()` fallback chain.
   - nil guards kept only at the `endpointInCooldown` / `markEndpointCooldown` 
boundaries, not in construction.
   - Tests: existing factory-sharing test now reads the field; added 
`TestIndependentPluginsDoNotShareCooldownState` proving two independently 
constructed plugins do not share state.
   
   Out-of-scope items from the issue (key semantics, TTL, eviction policy #943, 
persistence, background sweeper) are untouched.
   
   ## Acceptance criteria
   
   - [x] `sharedCooldownStore` removed
   - [x] Production request execution needs no multi-level fallback to locate 
cooldown state
   - [x] Existing cooldown tests pass with explicit store ownership
   - [x] New test covers isolation between independently constructed plugins
   - [x] `go test ./pkg/filter/llm/proxy/... ./pkg/server/... ./pkg/filter/...` 
pass; `gofmt`/`go vet` clean; `go build ./...` OK


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to