k8s.io/apiserver@v0.31.1/pkg/util/flowcontrol/metrics/union_gauge.go (about) 1 /* 2 Copyright 2022 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 metrics 18 19 type unionGauge []Gauge 20 21 var _ Gauge = unionGauge(nil) 22 23 // NewUnionGauge constructs a Gauge that delegates to all of the given Gauges 24 func NewUnionGauge(elts ...Gauge) Gauge { 25 return unionGauge(elts) 26 } 27 28 func (ug unionGauge) Set(x float64) { 29 for _, gauge := range ug { 30 gauge.Set(x) 31 } 32 } 33 34 func (ug unionGauge) Add(x float64) { 35 for _, gauge := range ug { 36 gauge.Add(x) 37 } 38 } 39 40 func (ug unionGauge) Inc() { 41 for _, gauge := range ug { 42 gauge.Inc() 43 } 44 } 45 46 func (ug unionGauge) Dec() { 47 for _, gauge := range ug { 48 gauge.Dec() 49 } 50 } 51 52 func (ug unionGauge) SetToCurrentTime() { 53 for _, gauge := range ug { 54 gauge.SetToCurrentTime() 55 } 56 }