k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/pkg/proxy/util/nfacct/nfacct.go (about) 1 /* 2 Copyright 2024 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 nfacct 18 19 // Counter represents a nfacct accounting object. 20 type Counter struct { 21 Name string 22 Packets uint64 23 Bytes uint64 24 } 25 26 // Interface is an injectable interface for running nfacct commands. 27 type Interface interface { 28 // Ensure checks the existence of a nfacct counter with the provided name and creates it if absent. 29 Ensure(name string) error 30 // Add creates a nfacct counter with the given name, returning an error if it already exists. 31 Add(name string) error 32 // Get retrieves the nfacct counter with the specified name, returning an error if it doesn't exist. 33 Get(name string) (*Counter, error) 34 // List retrieves all nfacct counters. 35 List() ([]*Counter, error) 36 }