From a3ea0c7bda6cae7a88af7dd005cd52ac40d42e57 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 17 Aug 2022 14:41:39 +0700 Subject: all: make the forwarders configuration fields to be generic Instead of single forwarder, Influxd, the Config struct now can have one or more forwarders. The kind of forwarders is defined by it subsection name, for example `[forwarder "influxd"]` defined a forwarder for influxd. --- config_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'config_test.go') diff --git a/config_test.go b/config_test.go index 779c59a..244bfa6 100644 --- a/config_test.go +++ b/config_test.go @@ -57,13 +57,15 @@ func TestLoad(t *testing.T) { desc: "With path exist", in: "testdata/haminer.conf", exp: &Config{ - Influxd: ConfigForwarder{ - Version: `v2`, - Url: `http://127.0.0.1:8086`, - Org: `kilabit.info`, - Bucket: `haproxy`, - apiWrite: `http://127.0.0.1:8086/api/v2/write?bucket=haproxy&org=kilabit.info&precision=ns`, - headerToken: `Token `, + Forwarders: map[string]*ConfigForwarder{ + `influxd`: &ConfigForwarder{ + Version: `v2`, + Url: `http://127.0.0.1:8086`, + Org: `kilabit.info`, + Bucket: `haproxy`, + apiWrite: `http://127.0.0.1:8086/api/v2/write?bucket=haproxy&org=kilabit.info&precision=ns`, + headerToken: `Token `, + }, }, Listen: `0.0.0.0:8080`, listenAddr: `0.0.0.0`, -- cgit v1.3