config

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT, Apache-2.0, MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigComment

func ConfigComment(t interface{}) ([]byte, error)

ConfigComment parse toml config to bytes

func CoverConfig

func CoverConfig(path string, config *Config) error

CoverConfig rewrite config

func GetStringSlicePreserveString

func GetStringSlicePreserveString(cfg Provider, key string) []string

GetStringSlicePreserveString returns a string slice from the given config and key. It differs from the GetStringSlice method in that if the config value is a string, we do not attempt to split it into fields.

Types

type APIConfig

type APIConfig struct {
	ListenAddress string `json:"listenAddress"`
}

rpc server address listen

type APIRegisterHubConfig added in v1.2.0

type APIRegisterHubConfig struct {
	RegisterAPI     []string `json:"apiRegisterHub"`
	Token           string   `json:"token"`
	SupportAccounts []string `json:"supportAccounts"`
}

type Config

type Config struct {
	API            *APIConfig            `json:"API"`
	DB             *DBConfig             `json:"DB" binding:"required"`
	Metrics        *MetricsConfig        `json:"METRICS"`
	JWT            *JWTConfig            `json:"JWT"`
	Factor         *CryptoFactor         `json:"FACTOR"`
	SignFilter     *SignFilter           `json:"SignFilter"`
	APIRegisterHub *APIRegisterHubConfig `json:"WalletEvent"`
	SignRecorder   *SignRecorderConfig   `json:"SignRecorder"`
}

full config

func DecodeConfig

func DecodeConfig(path string) (c *Config, err error)

DecodeConfig

type CryptoFactor

type CryptoFactor struct {
	// ScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	ScryptN int `json:"scryptN"`
	// ScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	ScryptP int `json:"scryptP"`
}

aes

type DBConfig

type DBConfig struct {
	Conn      string `json:"conn" binding:"required"`
	Type      string `json:"type" binding:"required"`
	DebugMode bool   `json:"debugMode" binding:"required"`
}

for keystore

type JWTConfig

type JWTConfig struct {
	Token  string `json:"token"`
	Secret string `json:"secret"`
}

jwt hex token and secret

type MetricsConfig

type MetricsConfig struct {
	Nickname   string `json:"nickName"`
	HeadNotify bool   `json:"headNotify"`
}

metrics

type Provider

type Provider interface {
	GetString(key string) string
	GetInt(key string) int
	GetBool(key string) bool
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringSlice(key string) []string
	Get(key string) interface{}
	Set(key string, value interface{})
	IsSet(key string) bool
	WatchConfig()
	OnConfigChange(run func(in fsnotify.Event))
	Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
	UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
}

func FromConfigString

func FromConfigString(path, configType string) (Provider, error)

FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.

type SignFilter added in v1.9.0

type SignFilter struct {
	Expr string `json:"expr"`
}

type SignRecorderConfig added in v1.13.0

type SignRecorderConfig struct {
	Enable       bool   `json:"enable"`
	KeepDuration string `json:"keepDuration"`
}

Jump to

Keyboard shortcuts

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