gosdk/metric/config.go

34 lines
447 B
Go
Raw Normal View History

2024-01-21 18:12:39 +08:00
package metric
var (
2024-01-21 22:54:16 +08:00
serv *service
TypeCount = "count"
TypeDuration = "duration"
2024-01-21 18:12:39 +08:00
)
type Config struct {
Address string
2024-01-21 18:49:51 +08:00
Username string
Password string
Database string
2024-01-21 18:12:39 +08:00
Interval int
}
func NewConfg() *Config {
return &Config{
2024-07-03 01:03:37 +08:00
Address: "http://10.0.2.157:8086",
2024-01-21 18:12:39 +08:00
Interval: 10,
2024-01-21 18:52:22 +08:00
Database: "telegraf",
2024-01-21 18:12:39 +08:00
}
}
func Init(c *Config) error {
if serv != nil {
return nil
}
2024-01-21 18:49:51 +08:00
serv = NewService(c)
2024-01-21 18:12:39 +08:00
go serv.run()
return nil
}