-
Notifications
You must be signed in to change notification settings - Fork 7
/
qos.go
46 lines (36 loc) · 1.01 KB
/
qos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package wrp
//go:generate stringer -type=QOSLevel -linecomment
// QOSLevel is the quality of service level associated with a WRP message.
type QOSLevel int
const (
QOSLow QOSLevel = iota // Low
QOSMedium // Medium
QOSHigh // High
QOSCritical // Critical
)
// QOSValue is the quality of service value set in a WRP message. Values of this
// type determine what QOSLevel a message has.
type QOSValue int
const (
QOSLowValue QOSValue = iota * 25
QOSMediumValue
QOSHighValue
QOSCriticalValue
)
// Level determines the QOSLevel for this value. Negative values are assumed
// to be QOSLow. Values higher than the highest value (99) are assumed to
// be QOSCritical.
func (qv QOSValue) Level() QOSLevel {
switch {
case qv < 25:
return QOSLow
case qv < 50:
return QOSMedium
case qv < 75:
return QOSHigh
default:
return QOSCritical
}
}