Debian Codegraph @

pkg/util/flowcontrol/fairqueuing/testing/no-restraint.go

raw
1 /*
2 Copyright 2019 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package testing
18
19 import (
20 "context"
21
22 "k8s.io/apiserver/pkg/util/flowcontrol/debug"
23 fq "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing"
24 "k8s.io/apiserver/pkg/util/flowcontrol/metrics"
25 fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request"
26 )
27
28 // NewNoRestraintFactory makes a QueueSetFactory that produces
29 // QueueSets that exert no restraint --- every request is dispatched
30 // for execution as soon as it arrives.
31 func NewNoRestraintFactory() fq.QueueSetFactory {
32 return noRestraintFactory{}
33 }
34
35 type noRestraintFactory struct{}
36
37 type noRestraintCompleter struct{}
38
39 type noRestraint struct{}
40
41 type noRestraintRequest struct{}
42
43 func (noRestraintFactory) BeginConstruction(fq.QueuingConfig, metrics.RatioedGaugePair, metrics.RatioedGauge, metrics.Gauge) (fq.QueueSetCompleter, error) {
44 return noRestraintCompleter{}, nil
45 }
46
47 func (noRestraintCompleter) Complete(dCfg fq.DispatchingConfig) fq.QueueSet {
48 return noRestraint{}
49 }
50
51 func (noRestraint) BeginConfigChange(qCfg fq.QueuingConfig) (fq.QueueSetCompleter, error) {
52 return noRestraintCompleter{}, nil
53 }
54
55 func (noRestraint) IsIdle() bool {
56 return false
57 }
58
59 func (noRestraint) StartRequest(ctx context.Context, workEstimate *fcrequest.WorkEstimate, hashValue uint64, flowDistinguisher, fsName string, descr1, descr2 interface{}, queueNoteFn fq.QueueNoteFn) (fq.Request, bool) {
60 return noRestraintRequest{}, false
61 }
62
63 func (noRestraint) Dump(bool) debug.QueueSetDump {
64 return debug.QueueSetDump{}
65 }
66
67 func (noRestraintRequest) Finish(execute func()) (idle bool) {
68 execute()
69 return false
70 }