aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-17 14:07:20 +0700
committerShulhan <ms@kilabit.info>2022-08-17 14:07:20 +0700
commite7476eed707355bbd0aa4e8fc1b3a025081068a0 (patch)
tree653cfb311e8c767eaa0630d131f6a7de7359ec35
parente09855572bece218df45df61c2eb8a106a9ef8de (diff)
downloadhaminer-e7476eed707355bbd0aa4e8fc1b3a025081068a0.tar.xz
all: rename struct InfluxdConfig to ConfigForwarder
Later we will have multiple forwarders, not only influxd.
-rw-r--r--config.go2
-rw-r--r--config_forwarder.go (renamed from influxd_config.go)6
-rw-r--r--config_test.go13
-rw-r--r--influxd_client.go4
4 files changed, 13 insertions, 12 deletions
diff --git a/config.go b/config.go
index 55daa62..a9786eb 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 InfluxdConfig
+ Influxd ConfigForwarder
// Listen is the address where Haminer will bind and receiving
// log from HAProxy.
diff --git a/influxd_config.go b/config_forwarder.go
index e2fdba2..357f562 100644
--- a/influxd_config.go
+++ b/config_forwarder.go
@@ -12,8 +12,8 @@ const (
influxdVersion2 = `v2`
)
-// InfluxdConfig contains configuration for forwarding the logs to Influxd.
-type InfluxdConfig struct {
+// ConfigForwarder contains configuration for forwarding the logs to Influxd.
+type ConfigForwarder struct {
Version string `ini:"forwarder:influxd:version"`
Url string `ini:"forwarder:influxd:url"`
@@ -34,7 +34,7 @@ type InfluxdConfig struct {
}
// init check, validate, and initialize the configuration values.
-func (cfg *InfluxdConfig) init() (err error) {
+func (cfg *ConfigForwarder) init() (err error) {
if len(cfg.Url) == 0 {
return
}
diff --git a/config_test.go b/config_test.go
index a836d86..779c59a 100644
--- a/config_test.go
+++ b/config_test.go
@@ -57,12 +57,13 @@ func TestLoad(t *testing.T) {
desc: "With path exist",
in: "testdata/haminer.conf",
exp: &Config{
- Influxd: InfluxdConfig{
- 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`,
+ 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`,
diff --git a/influxd_client.go b/influxd_client.go
index e096624..9c71523 100644
--- a/influxd_client.go
+++ b/influxd_client.go
@@ -47,13 +47,13 @@ const (
// InfluxdClient contains HTTP connection for writing logs to Influxd.
type InfluxdClient struct {
conn *http.Client
- cfg *InfluxdConfig
+ cfg *ConfigForwarder
hostname string
buf bytes.Buffer
}
// NewInfluxdClient will create, initialize, and return new Influxd client.
-func NewInfluxdClient(cfg *InfluxdConfig) (cl *InfluxdClient) {
+func NewInfluxdClient(cfg *ConfigForwarder) (cl *InfluxdClient) {
cl = &InfluxdClient{
cfg: cfg,
}