chore: move cfg
package to internal/cmd
This commit is contained in:
parent
8215e1f13a
commit
95a3a16fdc
1 changed files with 11 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
package cfg
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -15,15 +15,19 @@ type AppSettings struct {
|
|||
DataURL string
|
||||
CacheTTL time.Duration
|
||||
ReadHeaderTimeout time.Duration
|
||||
EnableExporter bool
|
||||
ExporterAddress string
|
||||
}
|
||||
|
||||
//nolint:lll // ignore line length
|
||||
type CLI struct {
|
||||
ServerAddress string `name:"listen-address" env:"GEOIP_LISTEN_ADDRESS" help:"Address to use for the metrics server" default:"${default_address}"`
|
||||
ServerAddress string `name:"listen-address" env:"GEOIP_LISTEN_ADDRESS" help:"Address to use for the api server" default:"${default_address}"`
|
||||
DataFile string `name:"data-file" env:"GEOIP_DATA_FILE" help:"path to data file" default:"${default_file_path}"`
|
||||
DataURL string `name:"data-url" env:"GEOIP_DATA_URL" help:"url to data file"`
|
||||
CacheTTL string `name:"cache-ttl" env:"GEOIP_CACHE_TTL" help:"ttl for response cache" default:"${default_cache_ttl}"`
|
||||
ReadHeaderTimeout string `name:"read-header-timeout" env:"GEOIP_READ_HEADER_TIMEOUT" help:"timeout for reading http header" default:"${default_read_header_timeout}"`
|
||||
EnableExporter bool `name:"enable-exporter" env:"GEOIP_ENABLE_EXPORTER" help:"enable prometheus exporter" default:"${default_enable_exporter}"`
|
||||
ExporterAddress string `name:"exporter-address" env:"GEOIP_EXPORTER_ADDRESS" help:"Address to use for the prometheus metrics server" default:"${default_exporter_address}"`
|
||||
}
|
||||
|
||||
func (c *CLI) Parse() (*AppSettings, error) {
|
||||
|
@ -34,8 +38,10 @@ func (c *CLI) Parse() (*AppSettings, error) {
|
|||
"default_file_path": "./data.csv",
|
||||
"default_cache_ttl": "2m",
|
||||
"default_read_header_timeout": "3s",
|
||||
"default_enable_exporter": "false",
|
||||
"default_exporter_address": ":9191",
|
||||
},
|
||||
kong.Name("country_geo_locations"),
|
||||
kong.Name("country-geo-locations"),
|
||||
kong.Description("🚀 Start a simple web server for GeoIP data"),
|
||||
kong.UsageOnError(),
|
||||
)
|
||||
|
@ -60,5 +66,7 @@ func (c *CLI) Parse() (*AppSettings, error) {
|
|||
DataURL: c.DataURL,
|
||||
CacheTTL: cacheTTL,
|
||||
ReadHeaderTimeout: readHeaderTimeout,
|
||||
EnableExporter: c.EnableExporter,
|
||||
ExporterAddress: c.ExporterAddress,
|
||||
}, nil
|
||||
}
|
Loading…
Reference in a new issue