-
Notifications
You must be signed in to change notification settings - Fork 186
refactor(registry): Replace event-driven GC with a lease-based lifecycle #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
66d8e28
ef56ab4
e77cab5
614d7c5
da9490d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can simply be in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| Copyright 2025 The Kubernetes Authors. | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package registry | ||
|
|
||
| import ( | ||
| "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/flowcontrol/contracts" | ||
| "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/flowcontrol/types" | ||
| ) | ||
|
|
||
| // connection is the concrete, un-exported implementation of the `contracts.ActiveFlowConnection` interface. | ||
| // It is a temporary handle created for the duration of a single `WithConnection` call. | ||
| type connection struct { | ||
| registry *FlowRegistry | ||
| key types.FlowKey | ||
| } | ||
|
|
||
| var _ contracts.ActiveFlowConnection = &connection{} | ||
|
|
||
| // Shards returns a stable snapshot of accessors for all internal state shards. | ||
| func (c *connection) Shards() []contracts.RegistryShard { | ||
| c.registry.mu.RLock() | ||
| defer c.registry.mu.RUnlock() | ||
|
|
||
| // Return a copy to ensure the caller cannot modify the registry's internal slice. | ||
| shardsCopy := make([]contracts.RegistryShard, len(c.registry.allShards)) | ||
| for i, s := range c.registry.allShards { | ||
| shardsCopy[i] = s | ||
| } | ||
| return shardsCopy | ||
| } |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dramatically shortened for doc maintainability (plus a lot of it became obsolete with the new lease-based model). Following principle of first disclosure by moving details closer to the relevant types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative here is:
FlowRegistryClient.Connectwith a correspondingActiveFlowConnection.Close. The functional approach is leak proof and more architecturally sound, but I am open to feedback here.Connect/Closealso works just fine with the flow control synchronous blocking model.e.g.,
Also, this method should eventually accept and respect caller context. I am not doing this in this PR as this will need to be done comprehensively across the flow control module contracts. As of right now, none of our function have unbounded blocking, so this is more for contract hardening and tracing than correctness at the moment.
I will do this in a separate PR.