From c0fca6d2bef5586109e739a6223d44f3bf986be5 Mon Sep 17 00:00:00 2001 From: Alessandro Puccetti Date: Tue, 16 Aug 2016 12:16:53 +0200 Subject: [PATCH] plugins/traffic-control: spilt getControls() This is done to make easier get specific controls when MetadataRow will accept controls. --- examples/plugins/traffic-control/report.go | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/examples/plugins/traffic-control/report.go b/examples/plugins/traffic-control/report.go index 91b261c37..295c0349b 100644 --- a/examples/plugins/traffic-control/report.go +++ b/examples/plugins/traffic-control/report.go @@ -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 = ";" func containerIDToNodeID(containerID string) string {