conf

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppYamlSchema = `` /* 1529-byte string literal not displayed */

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Server struct {
		ListenAddr     string         `yaml:"listen_addr" default:":8080"`
		Enabled        bool           `yaml:"enabled" default:"true"`
		DB             Datasource     `yaml:"datasource"`
		LeaderElection LeaderElection `yaml:"leader_election"`
	} `yaml:"server"`

	Exporter struct {
		ListenAddr string `yaml:"listen_addr" default:":9003"`
		Enabled    bool   `yaml:"enabled" default:"true"`
	} `yaml:"exporter"`
	Loader struct {
		Type   string         `yaml:"type" default:"FileLoader"`
		Config map[string]any `yaml:"config"`
	} `yaml:"loader"`
	Alert struct {
		Alertmanager struct {
			Enabled   bool   `yaml:"enabled" default:"false"`
			Url       string `yaml:"url"`
			BasicAuth struct {
				Username string `yaml:"username"`
				Password string `yaml:"password"`
			} `yaml:"basic_auth"`
		} `yaml:"alertmanager"`
		Generator struct {
			BaseUrl string          `yaml:"base_url"`
			Expire  xtime.TimeLimit `yaml:"expire"`
		} `yaml:"generator"`
	} `yaml:"alert"`
	Redis struct {
		Addr         string `yaml:"addr" default:"127.0.0.1"`
		Port         int    `yaml:"port" default:"6379"`
		Password     string `yaml:"password"`
		Db           int    `yaml:"db" default:"0"`
		PoolSize     int    `yaml:"pool_size" default:"512"`
		ReadTimeout  int    `yaml:"read_timeout" default:"30"`
		WriteTimeout int    `yaml:"write_timeout" default:"30"`
		DialTimeout  int    `yaml:"dial_timeout" default:"5"`
	} `yaml:"redis"`
	RunEvery          xtime.TimeLimit `yaml:"run_every"`
	BufferTime        xtime.TimeLimit `yaml:"buffer_time"`
	AlertTimeLimit    xtime.TimeLimit `yaml:"alert_time_limit"`
	MaxScrollingCount uint            `yaml:"max_scrolling_count" default:"5"`
}

AppConfig is application global configure

var AppConf *AppConfig

func GetAppConfig

func GetAppConfig(path string) *AppConfig

type Datasource

type Datasource struct {
	Type   string         `yaml:"type" default:"configmap"`
	Config map[string]any `yaml:"config"`
}

type FlagOption

type FlagOption struct {
	ConfigPath string `short:"c" long:"config" description:"config.yaml path" default:"./config.yaml"`
	Debug      bool   `long:"debug" description:"debug log level"`
	Verbose    string `short:"v" long:"verbose" description:"log level: debug、info、warn、error" default:"info"`
	Rule       string `long:"rule" description:"will only run the given single rule. The rule file may be a complete file path"`
	Zone       string `long:"zone" description:"time zone, e.g like PRC、UTC" default:"PRC"`
}

FlagOption is application run args

func (FlagOption) GetLogLevel

func (f FlagOption) GetLogLevel() log.Level

GetLogLevel can get application log level

func (FlagOption) IsDebug

func (f FlagOption) IsDebug() bool

type LeaderElection added in v1.2.0

type LeaderElection struct {
	Enabled   bool   `yaml:"enabled" default:"true"`
	Namespace string `yaml:"namespace" default:"default"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL