|
| 1 | +/* |
| 2 | +Copyright 2015 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 bandwidth |
| 18 | + |
| 19 | +import "k8s.io/apimachinery/pkg/api/resource" |
| 20 | + |
| 21 | +// Shaper is designed so that the shaper structs created |
| 22 | +// satisfy the Shaper interface. |
| 23 | +type Shaper interface { |
| 24 | + // Limit the bandwidth for a particular CIDR on a particular interface |
| 25 | + // * ingress and egress are in bits/second |
| 26 | + // * cidr is expected to be a valid network CIDR (e.g. '1.2.3.4/32' or '10.20.0.1/16') |
| 27 | + // 'egress' bandwidth limit applies to all packets on the interface whose source matches 'cidr' |
| 28 | + // 'ingress' bandwidth limit applies to all packets on the interface whose destination matches 'cidr' |
| 29 | + // Limits are aggregate limits for the CIDR, not per IP address. CIDRs must be unique, but can be overlapping, traffic |
| 30 | + // that matches multiple CIDRs counts against all limits. |
| 31 | + Limit(cidr string, egress, ingress *resource.Quantity) error |
| 32 | + // Remove a bandwidth limit for a particular CIDR on a particular network interface |
| 33 | + Reset(cidr string) error |
| 34 | + // Reconcile the interface managed by this shaper with the state on the ground. |
| 35 | + ReconcileInterface() error |
| 36 | + // Reconcile a CIDR managed by this shaper with the state on the ground |
| 37 | + ReconcileCIDR(cidr string, egress, ingress *resource.Quantity) error |
| 38 | + // GetCIDRs returns the set of CIDRs that are being managed by this shaper |
| 39 | + GetCIDRs() ([]string, error) |
| 40 | +} |
0 commit comments