Documentation
¶
Index ¶
- Variables
- func ConvertToMapInterface(v map[string]string) map[string]interface{}
- func ConvertToMapInterfaceSlice(m []map[string]string) []map[string]interface{}
- func DefaultTo(a, b string) string
- func FormatFloat(num float64, precision int) string
- func GetRegisterParam(config Config, c config_client.IConfigClient) (registerParam string, err error)
- func HTTPGet(addr string) ([]byte, error)
- func HTTPGetStr(addr string) (string, error)
- func HTTPInvoke(method, addr string, body []byte) ([]byte, error)
- func HTTPPost(addr string, body []byte) ([]byte, error)
- func HasBrace(s string, head, tail string) bool
- func HasPrefix(s string, prefix ...string) bool
- func If(condition bool, a, b string) string
- func IsHTTPAddress(s string) bool
- func IsJSONBytes(b []byte) bool
- func JSONDecode(v string) (interface{}, error)
- func MapInt(m map[string]interface{}, key string, defaultValue int) int
- func MapStr(m map[string]interface{}, key, defaultValue string) string
- func ParseConfig(configYamlFileName string, v any) error
- func PflagParse(f *pflag.FlagSet, args []string)
- func Pick1[T any](a T, _ ...any) T
- func ReadFile(filename string) []byte
- func ReadFileE(filename string) ([]byte, error)
- func ReadFileStrE(filename string) (string, error)
- func SetupSingals(sig ...os.Signal) context.Context
- func SetupSingalsWithContext(parent context.Context, sig ...os.Signal) context.Context
- func Sh(bash string) (*cmd.Cmd, cmd.Status)
- func SliceContains(ss []string, sub string) bool
- func Split2(s, sep string) (string, string)
- func TemplateEval(s string, data interface{}) (string, error)
- func ZeroTo(a, b int) int
- type Cfg
- type Cfgs
- type CommandResult
- type Config
- type DataSource
- type HTTPSource
- type KeyReader
- type KeyWriter
- type Mysql
- type Nacos
- type Redis
- type Result
- type ResultWriter
- type ServiceParam
- type Tpl
Constants ¶
This section is empty.
Variables ¶
var ErrCfg = errors.New("Errors in the config file")
ErrCfg defines the error type of bad config.
var InitAssets embed.FS
InitAssets gives the initial assets for the program initialization.
Functions ¶
func ConvertToMapInterface ¶
ConvertToMapInterface converts map[string]string to map[string]interface{}.
func ConvertToMapInterfaceSlice ¶
ConvertToMapInterfaceSlice convert slice of map[string]interface{} to slice of map[string]interface{}.
func FormatFloat ¶
FormatFloat format float with specified precision.
func GetRegisterParam ¶
func GetRegisterParam(config Config, c config_client.IConfigClient) (registerParam string, err error)
func HTTPInvoke ¶
HTTPInvoke execute HTTP method request.
func IsHTTPAddress ¶
IsHTTPAddress tests whether the string s starts with http:// or https://.
func JSONDecode ¶
JSONDecode decodes JSON string v to map[string]interface.
func ParseConfig ¶
func PflagParse ¶
PflagParse parses the plag and check unknown args.
func ReadFile ¶
ReadFile reads the file content of file with name filename. or panic if error happens.
func ReadFileStrE ¶
ReadFileStrE reads the file content of file with name filename.
func SetupSingals ¶
SetupSingals setups the signal.
func SetupSingalsWithContext ¶
SetupSingalsWithContext setups the signal.
func SliceContains ¶
SliceContains test if any element in slice contains sub.
func TemplateEval ¶
TemplateEval execute a template s with data.
Types ¶
type Cfg ¶
type Cfg struct {
Redis *Redis `hcl:"redis"`
Mysql *Mysql `hcl:"mysql"`
Nacos *Nacos `hcl:"nacos"`
Tpl Tpl `hcl:"tpl"`
// contains filtered or unexported fields
}
Cfg represents the root structure of the config.
type Cfgs ¶
type Cfgs []Cfg
Cfgs is alias for slice of Cfg.
func DecodeCfgFiles ¶
DecodeCfgFiles decodes the config files to Cfg structs.
type CommandResult ¶
type CommandResult struct {
ExecError error `json:"execError"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exitCode"`
}
CommandResult is the result of command execution.
type Config ¶
type Config struct {
ServerConfigs []constant.ServerConfig
ClientConfig constant.ClientConfig
RegisterParam *vo.ConfigParam
RegisterInstanceParam *vo.RegisterInstanceParam
}
type DataSource ¶
type DataSource interface {
Read() (interface{}, error)
}
DataSource defines the data source interface for reading the data.
type HTTPSource ¶
type HTTPSource struct {
Address string
}
HTTPSource defines the data source interface for reading the data from http.
func (HTTPSource) Read ¶
func (h HTTPSource) Read() (interface{}, error)
type Mysql ¶
type Mysql struct {
DataSourceName string `hcl:"dataSourceName"`
DataKey string `hcl:"dataKey"`
DataSQL string `hcl:"dataSql"`
Sqls map[string]string `hcl:"sqls"`
KVSql string `hcl:"kvSql"`
}
Mysql represents the structure of mysql config.
type Nacos ¶
type Nacos struct {
ConfigFile string `hcl:"configFile"`
ServiceParam ServiceParam `hcl:"serviceParam"`
// contains filtered or unexported fields
}
Nacos represents the structure of Nacos config.
type Redis ¶
type Redis struct {
Addr string `hcl:"addr"`
Password string `hcl:"password"`
ServicesKey string `hcl:"servicesKey"`
ResultKey string `hcl:"resultKey"`
Db int `hcl:"db"`
Cluster bool `hcl:"cluster"`
}
Redis represents the structure of redis config.
func (Redis) WriteResult ¶
WriteResult writes error.
type Result ¶
type Result struct {
Time string `json:"time"`
Old string `json:"old,omitempty"`
New string `json:"new,omitempty"`
Error string `json:"error,omitempty"`
StatusCode int `json:"statusCode"`
}
Result ...
type ResultWriter ¶
ResultWriter writes error.
type ServiceParam ¶
type ServiceParam struct {
ServiceName string `hcl:"ServiceName"` // required
GroupName string `hcl:"GroupName"` // optional,default:DEFAULT_GROUP
Clusters []string `hcl:"Clusters"` // optional,default:DEFAULT
}
ServiceParam map config for service discovery.
type Tpl ¶
type Tpl struct {
DataSource string `hcl:"dataSource"`
Interval string `hcl:"interval"`
TplSource string `hcl:"tplSource"`
Destination string `hcl:"destination"`
// 执行命令(包括测试命令)失败时,写入导致失败的内容
FailedDestination string `hcl:"failDestination"`
// 测试命令
TestCommand string `hcl:"testCommand"`
// 测试命令执行结果检查,例如有OK字眼,不配置,则只检测测试命令的执行状态
TestCommandCheck string `hcl:"testCommandCheck"`
Command string `hcl:"command"`
// 结果检查,例如有OK字眼,不配置,则只检测测试命令的执行状态ß
CommandCheck string `hcl:"commandCheck"`
Perms int `hcl:"perms"`
// contains filtered or unexported fields
}
Tpl represents a tpl config section.

