plugins/traffic-control: spilt getControls()

This is done to make easier get specific controls when MetadataRow will
accept controls.
This commit is contained in:
Alessandro Puccetti
2016-08-16 12:16:53 +02:00
parent 83c8e7af34
commit c0fca6d2be

View File

@@ -231,7 +231,7 @@ type extControl struct {
handler func(pid int) error
}
func getControls() []extControl {
func getLatencyControls() []extControl {
return []extControl{
{
control: control{
@@ -266,6 +266,11 @@ func getControls() []extControl {
return DoTrafficControl(pid, "1ms", "")
},
},
}
}
func getPktLossControls() []extControl {
return []extControl{
{
control: control{
ID: "pkt-drop-low",
@@ -277,6 +282,11 @@ func getControls() []extControl {
return DoTrafficControl(pid, "", "10%")
},
},
}
}
func getGeneralControls() []extControl {
return []extControl{
{
control: control{
ID: "clear",
@@ -291,6 +301,18 @@ func getControls() []extControl {
}
}
func getControls() []extControl {
controls := getLatencyControls()
// TODO alepuccetti why append(controls, getPktLossControls()) does not work?
for _, ctrl := range getPktLossControls() {
controls = append(controls, ctrl)
}
for _, ctrl := range getGeneralControls() {
controls = append(controls, ctrl)
}
return controls
}
const nodeSuffix = ";<container>"
func containerIDToNodeID(containerID string) string {