From 8cbd2c2db65ad308ee4d7e7503893660ed2fdc0f Mon Sep 17 00:00:00 2001 From: Alessandro Puccetti Date: Fri, 12 Aug 2016 13:33:29 +0200 Subject: [PATCH] plugins/traffic-control: create Traffic control table The traffic control plugin will display the status in this table. --- examples/plugins/traffic-control/report.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/plugins/traffic-control/report.go b/examples/plugins/traffic-control/report.go index 970209bc8..3ea8dab4d 100644 --- a/examples/plugins/traffic-control/report.go +++ b/examples/plugins/traffic-control/report.go @@ -16,6 +16,13 @@ type topology struct { Nodes map[string]node `json:"nodes"` Controls map[string]control `json:"controls"` MetadataTemplates map[string]metadataTemplate `json:"metadata_templates,omitempty"` + TableTemplates map[string]tableTemplate `json:"table_templates,omitempty"` +} + +type tableTemplate struct { + ID string `json:"id"` + Label string `json:"label"` + Prefix string `json:"prefix"` } type metadataTemplate struct { @@ -77,6 +84,7 @@ func (r *Reporter) RawReport() ([]byte, error) { Nodes: r.getContainerNodes(), Controls: getTrafficControls(), MetadataTemplates: getMetadataTemplate(), + TableTemplates: getTableTemplate(), }, Plugins: []pluginSpec{ { @@ -145,6 +153,10 @@ func (r *Reporter) getContainerNodes() map[string]node { Timestamp: timestamp, Value: latency, }, + "traffic-control-table-latency": { + Timestamp: timestamp, + Value: latency, + }, }, } } @@ -165,6 +177,16 @@ func getMetadataTemplate() map[string]metadataTemplate { } } +func getTableTemplate() map[string]tableTemplate { + return map[string]tableTemplate{ + "traffic-control-table": tableTemplate{ + ID: "traffic-control-table", + Label: "Traffic Control", + Prefix: "traffic-control-table-", + }, + } +} + func getTrafficNodeControls(timestamp time.Time, dead bool) map[string]controlEntry { controls := map[string]controlEntry{} entry := controlEntry{