conf

package
v0.0.0-...-fa4cddc Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]string

func (Config) BuildHttpCfg

func (cfg Config) BuildHttpCfg(log *util.ClientLogger) *HttpCfg

func (Config) BuildLogCfg

func (cfg Config) BuildLogCfg() *log2.Config

func (Config) BuildRetryCfg

func (cfg Config) BuildRetryCfg(log *util.ClientLogger) *RetryCfg

func (Config) BuildUserInfo

func (cfg Config) BuildUserInfo(Uid, Token string) (u *UserInfo)

func (Config) GetIntValue

func (cfg Config) GetIntValue(cfgName string, defaultVal int, log *util.ClientLogger) int

func (Config) GetStringValue

func (cfg Config) GetStringValue(cfgName string, defaultVal string, log *util.ClientLogger) string

type HttpCfg

type HttpCfg struct {
	Hosts           []string `json:"hosts"`              // The destination service address list, must not be empty
	TryTimes        uint32   `json:"try_times"`          // Maximum attempts for a request, TryTimes = RetryTimes + 1
	ClientTimeoutMS int      `json:"client_timeout_ms"`  // Timeout duration of the http client,see http.Client
	MaxFailsPeriodS int64    `json:"max_fails_period_s"` // Penalty time for failures

	ShouldRetry func(code int, err error) bool `json:"-"`
}

type RetryCfg

type RetryCfg struct {
	RetryTimes  int           //  maximum attempts
	RetryGap    time.Duration //  retry interval
	RetryFactor time.Duration //  retry penalty factor
}

type UserInfo

type UserInfo struct {
	// Unique user id. The third-party vendor must ensure that the ID is globally unique
	Uid string

	// User access token, used for authentication when accessing the server.
	// The third-party vendor determines the token generation rules and validity period.
	// The minimum validity period must be more than 10s. If it is too small,
	// the token may be expired before the request reaches the server
	Token string
}

Jump to

Keyboard shortcuts

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