aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-17 14:41:39 +0700
committerShulhan <ms@kilabit.info>2022-08-17 14:41:39 +0700
commita3ea0c7bda6cae7a88af7dd005cd52ac40d42e57 (patch)
tree4733d2ced445af2e87b173207e35c245cf8da32c /config.go
parentc28879b9d5f2f1bea96d5aaf64f1af1fc185e7b0 (diff)
downloadhaminer-a3ea0c7bda6cae7a88af7dd005cd52ac40d42e57.tar.xz
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.
Diffstat (limited to 'config.go')
-rw-r--r--config.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/config.go b/config.go
index a9786eb..3635638 100644
--- a/config.go
+++ b/config.go
@@ -22,7 +22,7 @@ const (
// Config define options to create and run Haminer instance.
type Config struct {
- Influxd ConfigForwarder
+ Forwarders map[string]*ConfigForwarder `ini:"forwarder"`
// Listen is the address where Haminer will bind and receiving
// log from HAProxy.
@@ -68,6 +68,7 @@ func (cfg *Config) Load(path string) (err error) {
logp = `Load`
in *ini.Ini
+ fw *ConfigForwarder
)
in, err = ini.Open(path)
@@ -89,9 +90,11 @@ func (cfg *Config) Load(path string) (err error) {
return fmt.Errorf(`%s: %w`, logp, err)
}
- err = cfg.Influxd.init()
- if err != nil {
- return fmt.Errorf(`%s: %w`, logp, err)
+ for _, fw = range cfg.Forwarders {
+ err = fw.init()
+ if err != nil {
+ return fmt.Errorf(`%s: %w`, logp, err)
+ }
}
return nil