1- package backend
1+ package config
22
33import (
44 "bytes"
88
99 "github.com/BurntSushi/toml"
1010 "github.com/uber-go/zap"
11- )
1211
13- const MetricEndpointLocal = "local"
12+ "github.com/lomik/graphite-clickhouse/helper/rollup"
13+ )
1414
1515// Duration wrapper time.Duration for TOML
1616type Duration struct {
@@ -36,7 +36,7 @@ func (d *Duration) Value() time.Duration {
3636 return d .Duration
3737}
3838
39- type commonConfig struct {
39+ type Common struct {
4040 Listen string `toml:"listen"`
4141 LogFile string `toml:"logfile"`
4242 LogLevel zap.Level `toml:"loglevel"`
@@ -46,7 +46,7 @@ type commonConfig struct {
4646 MaxCPU int `toml:"max-cpu"`
4747}
4848
49- type clickhouseConfig struct {
49+ type ClickHouse struct {
5050 Url string `toml:"url"`
5151 DataTable string `toml:"data-table"`
5252 DataTimeout * Duration `toml:"data-timeout"`
@@ -58,15 +58,15 @@ type clickhouseConfig struct {
5858
5959// Config ...
6060type Config struct {
61- Common commonConfig `toml:"common"`
62- ClickHouse clickhouseConfig `toml:"clickhouse"`
63- Rollup * Rollup `toml:"-"`
61+ Common Common `toml:"common"`
62+ ClickHouse ClickHouse `toml:"clickhouse"`
63+ Rollup * rollup. Rollup `toml:"-"`
6464}
6565
6666// NewConfig ...
67- func NewConfig () * Config {
67+ func New () * Config {
6868 cfg := & Config {
69- Common : commonConfig {
69+ Common : Common {
7070 Listen : ":9090" ,
7171 LogFile : "/var/log/graphite-clickhouse/graphite-clickhouse.log" ,
7272 LogLevel : zap .InfoLevel ,
@@ -77,7 +77,7 @@ func NewConfig() *Config {
7777 // MetricEndpoint: MetricEndpointLocal,
7878 MaxCPU : 1 ,
7979 },
80- ClickHouse : clickhouseConfig {
80+ ClickHouse : ClickHouse {
8181 Url : "http://localhost:8123" ,
8282
8383 DataTable : "graphite" ,
@@ -96,7 +96,7 @@ func NewConfig() *Config {
9696}
9797
9898// PrintConfig ...
99- func PrintConfig (cfg interface {}) error {
99+ func Print (cfg interface {}) error {
100100 buf := new (bytes.Buffer )
101101
102102 encoder := toml .NewEncoder (buf )
@@ -110,8 +110,8 @@ func PrintConfig(cfg interface{}) error {
110110 return nil
111111}
112112
113- // ParseConfig ...
114- func ParseConfig (filename string , cfg * Config ) error {
113+ // Parse ...
114+ func Parse (filename string , cfg * Config ) error {
115115 if filename != "" {
116116 if _ , err := toml .DecodeFile (filename , cfg ); err != nil {
117117 return err
@@ -123,7 +123,7 @@ func ParseConfig(filename string, cfg *Config) error {
123123 return err
124124 }
125125
126- r , err := ParseRollupXML (rollupConfBody )
126+ r , err := rollup . ParseXML (rollupConfBody )
127127 if err != nil {
128128 return err
129129 }
0 commit comments