Merge pull request #131200 from ntnn/kcp3350-client-go

Update docs on workqueue to match implementation

Kubernetes-commit: c34c70b2db75efc113402805d0a3bff391d13a79
This commit is contained in:
Kubernetes Publisher
2025-07-14 21:04:22 -07:00
3 changed files with 18 additions and 18 deletions

4
go.mod
View File

@@ -25,8 +25,8 @@ require (
golang.org/x/time v0.9.0
google.golang.org/protobuf v1.36.5
gopkg.in/evanphx/json-patch.v4 v4.12.0
k8s.io/api v0.0.0-20250705010445-839e6c7fb630
k8s.io/apimachinery v0.0.0-20250713050220-d5a1ab82b59b
k8s.io/api v0.0.0-20250715010522-2e37049d5e75
k8s.io/apimachinery v0.0.0-20250714234253-3b00b62c4bd9
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250628140032-d90c4fd18f59
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397

8
go.sum
View File

@@ -151,10 +151,10 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20250705010445-839e6c7fb630 h1:pnI9Db0bmtO4qa+X6jGK8WslPvzLwW8wrAe5B2//yGU=
k8s.io/api v0.0.0-20250705010445-839e6c7fb630/go.mod h1:cQb0K/knyMnN0b7QfEoYB+YzMbFk6PMoa/XTGxEJ7iw=
k8s.io/apimachinery v0.0.0-20250713050220-d5a1ab82b59b h1:DRtR8oFkFbWpltzifXbvp0pz3nIWBq2Vj+c/tq0/h94=
k8s.io/apimachinery v0.0.0-20250713050220-d5a1ab82b59b/go.mod h1:Th679JJyaVRDNFk3vKPKY43ypziDeoGnbEiEgBCz8s4=
k8s.io/api v0.0.0-20250715010522-2e37049d5e75 h1:Q0tnJOaq8j88vtw6m0TLQfZFrmXFyw9vkA5Gw35DV6o=
k8s.io/api v0.0.0-20250715010522-2e37049d5e75/go.mod h1:PiL1p1RqWH30UTFNXyVU6KxxDoYzYpbkXmp7MKgMSmU=
k8s.io/apimachinery v0.0.0-20250714234253-3b00b62c4bd9 h1:6tSGoqCLApU848BgnNQc3kFaz0DyHJmZb5S5kjuzlCk=
k8s.io/apimachinery v0.0.0-20250714234253-3b00b62c4bd9/go.mod h1:Th679JJyaVRDNFk3vKPKY43ypziDeoGnbEiEgBCz8s4=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20250628140032-d90c4fd18f59 h1:Jc4GiFTK2HHOpfQFoQEGXTBTs2pETwHukmoD4yoTqwo=

View File

@@ -212,7 +212,9 @@ type Typed[t comparable] struct {
clock clock.WithTicker
}
// Add marks item as needing processing.
// Add marks item as needing processing. When the queue is shutdown new
// items will silently be ignored and not queued or marked as dirty for
// reprocessing.
func (q *Typed[T]) Add(item T) {
q.cond.L.Lock()
defer q.cond.L.Unlock()
@@ -290,8 +292,9 @@ func (q *Typed[T]) Done(item T) {
}
}
// ShutDown will cause q to ignore all new items added to it and
// immediately instruct the worker goroutines to exit.
// ShutDown will cause q to ignore all new items added to it. Worker
// goroutines will continue processing items in the queue until it is
// empty and then receive the shutdown signal.
func (q *Typed[T]) ShutDown() {
q.cond.L.Lock()
defer q.cond.L.Unlock()
@@ -301,15 +304,12 @@ func (q *Typed[T]) ShutDown() {
q.cond.Broadcast()
}
// ShutDownWithDrain will cause q to ignore all new items added to it. As soon
// as the worker goroutines have "drained", i.e: finished processing and called
// Done on all existing items in the queue; they will be instructed to exit and
// ShutDownWithDrain will return. Hence: a strict requirement for using this is;
// your workers must ensure that Done is called on all items in the queue once
// the shut down has been initiated, if that is not the case: this will block
// indefinitely. It is, however, safe to call ShutDown after having called
// ShutDownWithDrain, as to force the queue shut down to terminate immediately
// without waiting for the drainage.
// ShutDownWithDrain is equivalent to ShutDown but waits until all items
// in the queue have been processed.
// ShutDown can be called after ShutDownWithDrain to force
// ShutDownWithDrain to stop waiting.
// Workers must call Done on an item after processing it, otherwise
// ShutDownWithDrain will block indefinitely.
func (q *Typed[T]) ShutDownWithDrain() {
q.cond.L.Lock()
defer q.cond.L.Unlock()