config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string, opts ...Option) (res interface{}, ok bool)

Get 非阻塞获取配置的key value

func GetBool

func GetBool(key string, opts ...Option) (v bool, ok bool)

func GetDuration

func GetDuration(key string, opts ...Option) (v time.Duration, ok bool)

func GetFloat

func GetFloat(key string, opts ...Option) (v float64, ok bool)

func GetInt

func GetInt(key string, opts ...Option) (v int64, ok bool)

func GetString

func GetString(key string, opts ...Option) (v string, ok bool)

func GetTime

func GetTime(key string, opts ...Option) (v time.Time, ok bool)

func Init

func Init()

Init 需要提前初始化,否则可能获取不到数据

func WatchConfig

func WatchConfig(f func(conf *Config), opts ...Option)

WatchConfig 订阅配置文件的变化,如果非空则第一次必推送 可能推送nil config

Types

type Config

type Config struct {
	config.Data
	// contains filtered or unexported fields
}

Config is tsf config

func GetConfig

func GetConfig(opts ...Option) *Config

GetConfig 获取配置文件

func (*Config) Get

func (c *Config) Get(key string) (v interface{}, ok bool)

func (*Config) GetBool

func (c *Config) GetBool(key string) (v bool, ok bool)

func (*Config) GetDuration

func (c *Config) GetDuration(key string) (v time.Duration, ok bool)

func (*Config) GetFloat

func (c *Config) GetFloat(key string) (v float64, ok bool)

func (*Config) GetInt

func (c *Config) GetInt(key string) (v int64, ok bool)

func (*Config) GetString

func (c *Config) GetString(key string) (v string, ok bool)

func (*Config) GetTime

func (c *Config) GetTime(key string) (v time.Time, ok bool)

func (*Config) Raw

func (c *Config) Raw() []byte

func (*Config) Unmarshal

func (c *Config) Unmarshal(v interface{}) error

type Option

type Option func(*options)

Option is config client option.

func WithGlobal

func WithGlobal(isGlobal bool) Option

WithGlobal is with global config

Jump to

Keyboard shortcuts

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