example

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllConfigOptionDeclareWithDefault added in v1.0.2

func AllConfigOptionDeclareWithDefault() interface{}

func AtomicAllConfigSet added in v1.0.2

func AtomicAllConfigSet(update interface{})

AtomicAllConfigSet atomic setter for *AllConfig

func AtomicConfigSet

func AtomicConfigSet(update interface{})

AtomicConfigSet atomic setter for *Config

func AtomicRedisSet added in v1.0.1

func AtomicRedisSet(update interface{})

AtomicRedisSet atomic setter for *Redis

func AtomicSpecSet

func AtomicSpecSet(update interface{})

AtomicSpecSet atomic setter for *spec

func AtomicXXXXXXSet added in v1.0.3

func AtomicXXXXXXSet(update interface{})

AtomicXXXXXXSet atomic setter for *XXXXXX

func ConfigOptionDeclareWithDefault

func ConfigOptionDeclareWithDefault() interface{}

func ETCDOptionDeclareWithDefault added in v1.0.2

func ETCDOptionDeclareWithDefault() interface{}

func InstallAllConfigWatchDog added in v1.0.2

func InstallAllConfigWatchDog(dog func(cc *AllConfig))

InstallAllConfigWatchDog the installed func will called when NewAllConfig called

func InstallCallbackOnAtomicAllConfigSet added in v1.0.2

func InstallCallbackOnAtomicAllConfigSet(callback func(cc AllConfigInterface) bool)

InstallCallbackOnAtomicAllConfigSet install callback

func InstallCallbackOnAtomicConfigSet added in v1.0.1

func InstallCallbackOnAtomicConfigSet(callback func(cc ConfigInterface) bool)

InstallCallbackOnAtomicConfigSet install callback

func InstallCallbackOnAtomicRedisSet added in v1.0.1

func InstallCallbackOnAtomicRedisSet(callback func(cc RedisInterface) bool)

InstallCallbackOnAtomicRedisSet install callback

func InstallCallbackOnAtomicSpecSet added in v1.0.1

func InstallCallbackOnAtomicSpecSet(callback func(cc SpecInterface) bool)

InstallCallbackOnAtomicSpecSet install callback

func InstallCallbackOnAtomicXXXXXXSet added in v1.0.3

func InstallCallbackOnAtomicXXXXXXSet(callback func(cc XXXXXXInterface) bool)

InstallCallbackOnAtomicXXXXXXSet install callback

func InstallConfigWatchDog

func InstallConfigWatchDog(dog func(cc *Config))

InstallConfigWatchDog the installed func will called when NewFuncNameSpecified called

func InstallETCDWatchDog added in v1.0.2

func InstallETCDWatchDog(dog func(cc *ETCD))

InstallETCDWatchDog the installed func will called when NewETCD called

func InstallRedisWatchDog added in v1.0.1

func InstallRedisWatchDog(dog func(cc *Redis))

InstallRedisWatchDog the installed func will called when NewRedis called

func InstallSpecWatchDog

func InstallSpecWatchDog(dog func(cc *spec))

InstallSpecWatchDog the installed func will called when NewSpec called

func InstallXXXXXXWatchDog added in v1.0.2

func InstallXXXXXXWatchDog(dog func(cc *XXXXXX))

InstallXXXXXXWatchDog the installed func will called when NewXXXXXX called

func NewSpec

func NewSpec(opts ...SpecOption) *spec

NewSpec new spec

func RedisOptionDeclareWithDefault added in v1.0.1

func RedisOptionDeclareWithDefault() interface{}

func XXXXXXOptionDeclareWithDefault added in v1.0.2

func XXXXXXOptionDeclareWithDefault() interface{}

Types

type AllConfig added in v1.0.2

type AllConfig struct {
	TypeBool          bool            `xconf:"type_bool"`
	TypeString        string          `xconf:"type_string"`
	TypeDuration      time.Duration   `xconf:"type_duration"`
	TypeFloat32       float32         `xconf:"type_float32"`
	TypeFloat64       float32         `xconf:"type_float64"`
	TypeInt           int             `xconf:"type_int"`
	TypeUint          int             `xconf:"type_uint"`
	TypeInt8          int8            `xconf:"type_int8"`
	TypeUint8         uint8           `xconf:"type_uint8"`
	TypeInt16         int16           `xconf:"type_int16"`
	TypeUint16        uint16          `xconf:"type_uint16"`
	TypeInt32         int32           `xconf:"type_int32"`
	TypeUint32        uint32          `xconf:"type_uint32"`
	TypeInt64         int64           `xconf:"type_int64"`
	TypeUint64        uint64          `xconf:"type_uint64"`
	TypeSliceInt      []int           `xconf:"type_slice_int"`
	TypeSliceUint     []uint          `xconf:"type_slice_uint"`
	TypeSliceInt8     []int8          `xconf:"type_slice_int8"`
	TypeSliceUint8    []uint8         `xconf:"type_slice_uint8"`
	TypeSliceInt16    []int16         `xconf:"type_slice_int16"`
	TypeSliceUin16    []uint16        `xconf:"type_slice_uin16"`
	TypeSliceInt32    []int32         `xconf:"type_slice_int32"`
	TypeSliceUint32   []uint32        `xconf:"type_slice_uint32"`
	TypeSliceInt64    []int64         `xconf:"type_slice_int64"`
	TypeSliceUint64   []uint64        `xconf:"type_slice_uint64"`
	TypeSliceString   []string        `xconf:"type_slice_string"`
	TypeSliceFloat32  []float32       `xconf:"type_slice_float32"`
	TypeSliceFloat64  []float64       `xconf:"type_slice_float64"`
	TypeSliceDuratuon []time.Duration `xconf:"type_slice_duratuon"`
	// annotation@TypeMapStringIntNotLeaf(xconf="type_map_string_int_not_leaf,notleaf")
	TypeMapStringIntNotLeaf map[string]int           `xconf:"type_map_string_int_not_leaf,notleaf"`
	TypeMapStringInt        map[string]int           `xconf:"type_map_string_int"`
	TypeMapIntString        map[int]string           `xconf:"type_map_int_string"`
	TypeMapStringString     map[string]string        `xconf:"type_map_string_string"`
	TypeMapIntInt           map[int]int              `xconf:"type_map_int_int"`
	TypeMapStringDuration   map[string]time.Duration `xconf:"type_map_string_duration"`
	// annotation@Redis(getter="RedisVisitor")
	Redis         *Redis      `xconf:"redis"`
	ETCD          *ETCD       `xconf:"etcd"`
	TestInterface interface{} `xconf:"test_interface"`
}

AllConfig should use NewAllConfig to initialize it

func NewAllConfig added in v1.0.2

func NewAllConfig(opts ...AllConfigOption) *AllConfig

NewAllConfig new AllConfig

func (*AllConfig) ApplyOption added in v1.0.2

func (cc *AllConfig) ApplyOption(opts ...AllConfigOption) []AllConfigOption

ApplyOption apply mutiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)

func (*AllConfig) AtomicSetFunc added in v1.0.2

func (cc *AllConfig) AtomicSetFunc() func(interface{})

AtomicSetFunc used for XConf

func (*AllConfig) GetETCD added in v1.0.2

func (cc *AllConfig) GetETCD() *ETCD

func (*AllConfig) GetRedis added in v1.0.2

func (cc *AllConfig) GetRedis() RedisVisitor

func (*AllConfig) GetTestInterface added in v1.0.2

func (cc *AllConfig) GetTestInterface() interface{}

func (*AllConfig) GetTypeBool added in v1.0.2

func (cc *AllConfig) GetTypeBool() bool

all getter func

func (*AllConfig) GetTypeDuration added in v1.0.2

func (cc *AllConfig) GetTypeDuration() time.Duration

func (*AllConfig) GetTypeFloat32 added in v1.0.2

func (cc *AllConfig) GetTypeFloat32() float32

func (*AllConfig) GetTypeFloat64 added in v1.0.2

func (cc *AllConfig) GetTypeFloat64() float32

func (*AllConfig) GetTypeInt added in v1.0.2

func (cc *AllConfig) GetTypeInt() int

func (*AllConfig) GetTypeInt16 added in v1.0.2

func (cc *AllConfig) GetTypeInt16() int16

func (*AllConfig) GetTypeInt32 added in v1.0.2

func (cc *AllConfig) GetTypeInt32() int32

func (*AllConfig) GetTypeInt64 added in v1.0.2

func (cc *AllConfig) GetTypeInt64() int64

func (*AllConfig) GetTypeInt8 added in v1.0.2

func (cc *AllConfig) GetTypeInt8() int8

func (*AllConfig) GetTypeMapIntInt added in v1.0.2

func (cc *AllConfig) GetTypeMapIntInt() map[int]int

func (*AllConfig) GetTypeMapIntString added in v1.0.2

func (cc *AllConfig) GetTypeMapIntString() map[int]string

func (*AllConfig) GetTypeMapStringDuration added in v1.0.2

func (cc *AllConfig) GetTypeMapStringDuration() map[string]time.Duration

func (*AllConfig) GetTypeMapStringInt added in v1.0.2

func (cc *AllConfig) GetTypeMapStringInt() map[string]int

func (*AllConfig) GetTypeMapStringIntNotLeaf added in v1.0.2

func (cc *AllConfig) GetTypeMapStringIntNotLeaf() map[string]int

func (*AllConfig) GetTypeMapStringString added in v1.0.2

func (cc *AllConfig) GetTypeMapStringString() map[string]string

func (*AllConfig) GetTypeSliceDuratuon added in v1.0.2

func (cc *AllConfig) GetTypeSliceDuratuon() []time.Duration

func (*AllConfig) GetTypeSliceFloat32 added in v1.0.2

func (cc *AllConfig) GetTypeSliceFloat32() []float32

func (*AllConfig) GetTypeSliceFloat64 added in v1.0.2

func (cc *AllConfig) GetTypeSliceFloat64() []float64

func (*AllConfig) GetTypeSliceInt added in v1.0.2

func (cc *AllConfig) GetTypeSliceInt() []int

func (*AllConfig) GetTypeSliceInt16 added in v1.0.2

func (cc *AllConfig) GetTypeSliceInt16() []int16

func (*AllConfig) GetTypeSliceInt32 added in v1.0.2

func (cc *AllConfig) GetTypeSliceInt32() []int32

func (*AllConfig) GetTypeSliceInt64 added in v1.0.2

func (cc *AllConfig) GetTypeSliceInt64() []int64

func (*AllConfig) GetTypeSliceInt8 added in v1.0.2

func (cc *AllConfig) GetTypeSliceInt8() []int8

func (*AllConfig) GetTypeSliceString added in v1.0.2

func (cc *AllConfig) GetTypeSliceString() []string

func (*AllConfig) GetTypeSliceUin16 added in v1.0.2

func (cc *AllConfig) GetTypeSliceUin16() []uint16

func (*AllConfig) GetTypeSliceUint added in v1.0.2

func (cc *AllConfig) GetTypeSliceUint() []uint

func (*AllConfig) GetTypeSliceUint32 added in v1.0.2

func (cc *AllConfig) GetTypeSliceUint32() []uint32

func (*AllConfig) GetTypeSliceUint64 added in v1.0.2

func (cc *AllConfig) GetTypeSliceUint64() []uint64

func (*AllConfig) GetTypeSliceUint8 added in v1.0.2

func (cc *AllConfig) GetTypeSliceUint8() []uint8

func (*AllConfig) GetTypeString added in v1.0.2

func (cc *AllConfig) GetTypeString() string

func (*AllConfig) GetTypeUint added in v1.0.2

func (cc *AllConfig) GetTypeUint() int

func (*AllConfig) GetTypeUint16 added in v1.0.2

func (cc *AllConfig) GetTypeUint16() uint16

func (*AllConfig) GetTypeUint32 added in v1.0.2

func (cc *AllConfig) GetTypeUint32() uint32

func (*AllConfig) GetTypeUint64 added in v1.0.2

func (cc *AllConfig) GetTypeUint64() uint64

func (*AllConfig) GetTypeUint8 added in v1.0.2

func (cc *AllConfig) GetTypeUint8() uint8

type AllConfigInterface added in v1.0.2

type AllConfigInterface interface {
	AllConfigVisitor
	ApplyOption(...AllConfigOption) []AllConfigOption
}

AllConfigInterface visitor + ApplyOption interface for AllConfig

type AllConfigOption added in v1.0.2

type AllConfigOption func(cc *AllConfig) AllConfigOption

AllConfigOption option func

func WithETCD added in v1.0.2

func WithETCD(v *ETCD) AllConfigOption

WithETCD option func for filed ETCD

func WithRedis added in v1.0.2

func WithRedis(v *Redis) AllConfigOption

WithRedis option func for filed Redis

func WithTestInterface added in v1.0.2

func WithTestInterface(v interface{}) AllConfigOption

WithTestInterface option func for filed TestInterface

func WithTypeBool added in v1.0.2

func WithTypeBool(v bool) AllConfigOption

WithTypeBool option func for filed TypeBool

func WithTypeDuration added in v1.0.2

func WithTypeDuration(v time.Duration) AllConfigOption

WithTypeDuration option func for filed TypeDuration

func WithTypeFloat32 added in v1.0.2

func WithTypeFloat32(v float32) AllConfigOption

WithTypeFloat32 option func for filed TypeFloat32

func WithTypeFloat64 added in v1.0.2

func WithTypeFloat64(v float32) AllConfigOption

WithTypeFloat64 option func for filed TypeFloat64

func WithTypeInt added in v1.0.2

func WithTypeInt(v int) AllConfigOption

WithTypeInt option func for filed TypeInt

func WithTypeInt16 added in v1.0.2

func WithTypeInt16(v int16) AllConfigOption

WithTypeInt16 option func for filed TypeInt16

func WithTypeInt32 added in v1.0.2

func WithTypeInt32(v int32) AllConfigOption

WithTypeInt32 option func for filed TypeInt32

func WithTypeInt64 added in v1.0.2

func WithTypeInt64(v int64) AllConfigOption

WithTypeInt64 option func for filed TypeInt64

func WithTypeInt8 added in v1.0.2

func WithTypeInt8(v int8) AllConfigOption

WithTypeInt8 option func for filed TypeInt8

func WithTypeMapIntInt added in v1.0.2

func WithTypeMapIntInt(v map[int]int) AllConfigOption

WithTypeMapIntInt option func for filed TypeMapIntInt

func WithTypeMapIntString added in v1.0.2

func WithTypeMapIntString(v map[int]string) AllConfigOption

WithTypeMapIntString option func for filed TypeMapIntString

func WithTypeMapStringDuration added in v1.0.2

func WithTypeMapStringDuration(v map[string]time.Duration) AllConfigOption

WithTypeMapStringDuration option func for filed TypeMapStringDuration

func WithTypeMapStringInt added in v1.0.2

func WithTypeMapStringInt(v map[string]int) AllConfigOption

WithTypeMapStringInt option func for filed TypeMapStringInt

func WithTypeMapStringIntNotLeaf added in v1.0.2

func WithTypeMapStringIntNotLeaf(v map[string]int) AllConfigOption

WithTypeMapStringIntNotLeaf option func for filed TypeMapStringIntNotLeaf

func WithTypeMapStringString added in v1.0.2

func WithTypeMapStringString(v map[string]string) AllConfigOption

WithTypeMapStringString option func for filed TypeMapStringString

func WithTypeSliceDuratuon added in v1.0.2

func WithTypeSliceDuratuon(v ...time.Duration) AllConfigOption

WithTypeSliceDuratuon option func for filed TypeSliceDuratuon

func WithTypeSliceFloat32 added in v1.0.2

func WithTypeSliceFloat32(v ...float32) AllConfigOption

WithTypeSliceFloat32 option func for filed TypeSliceFloat32

func WithTypeSliceFloat64 added in v1.0.2

func WithTypeSliceFloat64(v ...float64) AllConfigOption

WithTypeSliceFloat64 option func for filed TypeSliceFloat64

func WithTypeSliceInt added in v1.0.2

func WithTypeSliceInt(v ...int) AllConfigOption

WithTypeSliceInt option func for filed TypeSliceInt

func WithTypeSliceInt16 added in v1.0.2

func WithTypeSliceInt16(v ...int16) AllConfigOption

WithTypeSliceInt16 option func for filed TypeSliceInt16

func WithTypeSliceInt32 added in v1.0.2

func WithTypeSliceInt32(v ...int32) AllConfigOption

WithTypeSliceInt32 option func for filed TypeSliceInt32

func WithTypeSliceInt64 added in v1.0.2

func WithTypeSliceInt64(v ...int64) AllConfigOption

WithTypeSliceInt64 option func for filed TypeSliceInt64

func WithTypeSliceInt8 added in v1.0.2

func WithTypeSliceInt8(v ...int8) AllConfigOption

WithTypeSliceInt8 option func for filed TypeSliceInt8

func WithTypeSliceString added in v1.0.2

func WithTypeSliceString(v ...string) AllConfigOption

WithTypeSliceString option func for filed TypeSliceString

func WithTypeSliceUin16 added in v1.0.2

func WithTypeSliceUin16(v ...uint16) AllConfigOption

WithTypeSliceUin16 option func for filed TypeSliceUin16

func WithTypeSliceUint added in v1.0.2

func WithTypeSliceUint(v ...uint) AllConfigOption

WithTypeSliceUint option func for filed TypeSliceUint

func WithTypeSliceUint32 added in v1.0.2

func WithTypeSliceUint32(v ...uint32) AllConfigOption

WithTypeSliceUint32 option func for filed TypeSliceUint32

func WithTypeSliceUint64 added in v1.0.2

func WithTypeSliceUint64(v ...uint64) AllConfigOption

WithTypeSliceUint64 option func for filed TypeSliceUint64

func WithTypeSliceUint8 added in v1.0.2

func WithTypeSliceUint8(v ...uint8) AllConfigOption

WithTypeSliceUint8 option func for filed TypeSliceUint8

func WithTypeString added in v1.0.2

func WithTypeString(v string) AllConfigOption

WithTypeString option func for filed TypeString

func WithTypeUint added in v1.0.2

func WithTypeUint(v int) AllConfigOption

WithTypeUint option func for filed TypeUint

func WithTypeUint16 added in v1.0.2

func WithTypeUint16(v uint16) AllConfigOption

WithTypeUint16 option func for filed TypeUint16

func WithTypeUint32 added in v1.0.2

func WithTypeUint32(v uint32) AllConfigOption

WithTypeUint32 option func for filed TypeUint32

func WithTypeUint64 added in v1.0.2

func WithTypeUint64(v uint64) AllConfigOption

WithTypeUint64 option func for filed TypeUint64

func WithTypeUint8 added in v1.0.2

func WithTypeUint8(v uint8) AllConfigOption

WithTypeUint8 option func for filed TypeUint8

type AllConfigVisitor added in v1.0.2

type AllConfigVisitor interface {
	GetTypeBool() bool
	GetTypeString() string
	GetTypeDuration() time.Duration
	GetTypeFloat32() float32
	GetTypeFloat64() float32
	GetTypeInt() int
	GetTypeUint() int
	GetTypeInt8() int8
	GetTypeUint8() uint8
	GetTypeInt16() int16
	GetTypeUint16() uint16
	GetTypeInt32() int32
	GetTypeUint32() uint32
	GetTypeInt64() int64
	GetTypeUint64() uint64
	GetTypeSliceInt() []int
	GetTypeSliceUint() []uint
	GetTypeSliceInt8() []int8
	GetTypeSliceUint8() []uint8
	GetTypeSliceInt16() []int16
	GetTypeSliceUin16() []uint16
	GetTypeSliceInt32() []int32
	GetTypeSliceUint32() []uint32
	GetTypeSliceInt64() []int64
	GetTypeSliceUint64() []uint64
	GetTypeSliceString() []string
	GetTypeSliceFloat32() []float32
	GetTypeSliceFloat64() []float64
	GetTypeSliceDuratuon() []time.Duration
	GetTypeMapStringIntNotLeaf() map[string]int
	GetTypeMapStringInt() map[string]int
	GetTypeMapIntString() map[int]string
	GetTypeMapStringString() map[string]string
	GetTypeMapIntInt() map[int]int
	GetTypeMapStringDuration() map[string]time.Duration
	GetRedis() RedisVisitor
	GetETCD() *ETCD
	GetTestInterface() interface{}
}

AllConfigVisitor visitor interface for AllConfig

func AtomicAllConfig added in v1.0.2

func AtomicAllConfig() AllConfigVisitor

AtomicAllConfig return atomic *AllConfigVisitor

type Config

type Config struct {
	// test comment 1
	// annotation@TestNil(option="WithTTTTTTTT")
	TestNil             interface{}       `xconf:"test_nil"` // test comment 3
	TestInt             int               `xconf:"test_int" usage:"这里是函数注释1,\"test\" , 这里是函数注释2"`
	TestInt64           int64             `xconf:"test_int64"`
	TestSliceInt        []int             `xconf:"test_slice_int"`
	TestSliceInt64      []int64           `xconf:"test_slice_int64"`
	TestSliceString     []string          `xconf:"test_slice_string"`
	TestSliceBool       []bool            `xconf:"test_slice_bool"`
	TestSliceIntNil     []int             `xconf:"test_slice_int_nil"`
	TestSliceByte       []byte            `xconf:"test_slice_byte"`
	TestSliceIntEmpty   []int             `xconf:"test_slice_int_empty"`
	TestHTTPPort        string            `xconf:"test_http_port"`
	TestEmptyMap        map[int]int       `xconf:"test_empty_map"`
	TestMapIntInt       map[int]int       `xconf:"test_map_int_int"`
	TestMapIntString    map[int]string    `xconf:"test_map_int_string"`
	TestMapStringInt    map[string]int    `xconf:"test_map_string_int"`
	TestMapStringString map[string]string `xconf:"test_map_string_string"`
	TestString          string            `xconf:"test_string"`
	Food                *string           `xconf:"food"`
	Walk                func()            `xconf:"walk"`
	TestNilFunc         func()            `xconf:"test_nil_func"` // 中文1
	SubTest             *SubTest          `xconf:"sub_test"`
	// annotation@Paths(inline="true")
	Paths `xconf:"paths"`
	// annotation@TestProtected(private="true")
	TestProtected []byte `xconf:"test_protected"`
	// annotation@fOO(inline="true")
	*FOO    `xconf:"f_oo"`
	SpecSub *spec `xconf:"spec_sub"` // annotation@SpecSub(getter="SpecVisitor")
	// annotation@TestParamterBool(arg=1)
	TestParamterBool bool `xconf:"test_paramter_bool"` // reserved parameter 1
	// annotation@TestParamterStr(arg=22)
	TestParamterStr string `xconf:"test_paramter_str"` // reserved parameter 2
}

Config should use NewFuncNameSpecified to initialize it

func (*Config) ApplyOption

func (cc *Config) ApplyOption(opts ...ConfigOption) []ConfigOption

ApplyOption apply mutiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)

func (*Config) AtomicSetFunc

func (cc *Config) AtomicSetFunc() func(interface{})

AtomicSetFunc used for XConf

func (*Config) GetFOO

func (cc *Config) GetFOO() *FOO

func (*Config) GetFood

func (cc *Config) GetFood() *string

func (*Config) GetPaths added in v1.0.4

func (cc *Config) GetPaths() Paths

func (*Config) GetSpecSub

func (cc *Config) GetSpecSub() SpecVisitor

func (*Config) GetSubTest

func (cc *Config) GetSubTest() *SubTest

func (*Config) GetTestEmptyMap

func (cc *Config) GetTestEmptyMap() map[int]int

func (*Config) GetTestHTTPPort

func (cc *Config) GetTestHTTPPort() string

func (*Config) GetTestInt

func (cc *Config) GetTestInt() int

func (*Config) GetTestInt64

func (cc *Config) GetTestInt64() int64

func (*Config) GetTestMapIntInt

func (cc *Config) GetTestMapIntInt() map[int]int

func (*Config) GetTestMapIntString

func (cc *Config) GetTestMapIntString() map[int]string

func (*Config) GetTestMapStringInt

func (cc *Config) GetTestMapStringInt() map[string]int

func (*Config) GetTestMapStringString

func (cc *Config) GetTestMapStringString() map[string]string

func (*Config) GetTestNil

func (cc *Config) GetTestNil() interface{}

all getter func

func (*Config) GetTestNilFunc

func (cc *Config) GetTestNilFunc() func()

func (*Config) GetTestParamterBool

func (cc *Config) GetTestParamterBool() bool

func (*Config) GetTestParamterStr

func (cc *Config) GetTestParamterStr() string

func (*Config) GetTestProtected

func (cc *Config) GetTestProtected() []byte

func (*Config) GetTestSliceBool

func (cc *Config) GetTestSliceBool() []bool

func (*Config) GetTestSliceByte

func (cc *Config) GetTestSliceByte() []byte

func (*Config) GetTestSliceInt

func (cc *Config) GetTestSliceInt() []int

func (*Config) GetTestSliceInt64

func (cc *Config) GetTestSliceInt64() []int64

func (*Config) GetTestSliceIntEmpty

func (cc *Config) GetTestSliceIntEmpty() []int

func (*Config) GetTestSliceIntNil

func (cc *Config) GetTestSliceIntNil() []int

func (*Config) GetTestSliceString

func (cc *Config) GetTestSliceString() []string

func (*Config) GetTestString

func (cc *Config) GetTestString() string

func (*Config) GetWalk

func (cc *Config) GetWalk() func()

type ConfigInterface

type ConfigInterface interface {
	ConfigVisitor
	ApplyOption(...ConfigOption) []ConfigOption
}

ConfigInterface visitor + ApplyOption interface for Config

func NewFuncNameSpecified

func NewFuncNameSpecified(testParamterBool bool, testParamterStr string, opts ...ConfigOption) ConfigInterface

NewFuncNameSpecified new Config

type ConfigOption

type ConfigOption func(cc *Config) ConfigOption

ConfigOption option func

func WithFOO

func WithFOO(v *FOO) ConfigOption

WithFOO option func for filed FOO

func WithFood

func WithFood(v *string) ConfigOption

WithFood option func for filed Food

func WithPaths added in v1.0.4

func WithPaths(v Paths) ConfigOption

WithPaths option func for filed Paths

func WithSpecSub

func WithSpecSub(v *spec) ConfigOption

WithSpecSub option func for filed SpecSub

func WithSubTest

func WithSubTest(v *SubTest) ConfigOption

WithSubTest option func for filed SubTest

func WithTTTTTTTT

func WithTTTTTTTT(v interface{}) ConfigOption

WithTTTTTTTT option func for filed TestNil

func WithTestEmptyMap

func WithTestEmptyMap(v map[int]int) ConfigOption

WithTestEmptyMap option func for filed TestEmptyMap

func WithTestHTTPPort

func WithTestHTTPPort(v string) ConfigOption

WithTestHTTPPort option func for filed TestHTTPPort

func WithTestInt

func WithTestInt(v int) ConfigOption

WithTestInt 这里是函数注释1,"test",这里是函数注释2

func WithTestInt64

func WithTestInt64(v int64) ConfigOption

WithTestInt64 option func for filed TestInt64

func WithTestMapIntInt

func WithTestMapIntInt(v map[int]int) ConfigOption

WithTestMapIntInt option func for filed TestMapIntInt

func WithTestMapIntString

func WithTestMapIntString(v map[int]string) ConfigOption

WithTestMapIntString option func for filed TestMapIntString

func WithTestMapStringInt

func WithTestMapStringInt(v map[string]int) ConfigOption

WithTestMapStringInt option func for filed TestMapStringInt

func WithTestMapStringString

func WithTestMapStringString(v map[string]string) ConfigOption

WithTestMapStringString option func for filed TestMapStringString

func WithTestNilFunc

func WithTestNilFunc(v func()) ConfigOption

WithTestNilFunc option func for filed TestNilFunc

func WithTestSliceBool

func WithTestSliceBool(v ...bool) ConfigOption

WithTestSliceBool option func for filed TestSliceBool

func WithTestSliceByte

func WithTestSliceByte(v []byte) ConfigOption

WithTestSliceByte option func for filed TestSliceByte

func WithTestSliceInt

func WithTestSliceInt(v ...int) ConfigOption

WithTestSliceInt option func for filed TestSliceInt

func WithTestSliceInt64

func WithTestSliceInt64(v ...int64) ConfigOption

WithTestSliceInt64 option func for filed TestSliceInt64

func WithTestSliceIntEmpty

func WithTestSliceIntEmpty(v ...int) ConfigOption

WithTestSliceIntEmpty option func for filed TestSliceIntEmpty

func WithTestSliceIntNil

func WithTestSliceIntNil(v ...int) ConfigOption

WithTestSliceIntNil option func for filed TestSliceIntNil

func WithTestSliceString

func WithTestSliceString(v ...string) ConfigOption

WithTestSliceString option func for filed TestSliceString

func WithTestString

func WithTestString(v string) ConfigOption

WithTestString option func for filed TestString

func WithWalk

func WithWalk(v func()) ConfigOption

WithWalk option func for filed Walk

type ConfigVisitor

type ConfigVisitor interface {
	GetTestNil() interface{}
	GetTestInt() int
	GetTestInt64() int64
	GetTestSliceInt() []int
	GetTestSliceInt64() []int64
	GetTestSliceString() []string
	GetTestSliceBool() []bool
	GetTestSliceIntNil() []int
	GetTestSliceByte() []byte
	GetTestSliceIntEmpty() []int
	GetTestHTTPPort() string
	GetTestEmptyMap() map[int]int
	GetTestMapIntInt() map[int]int
	GetTestMapIntString() map[int]string
	GetTestMapStringInt() map[string]int
	GetTestMapStringString() map[string]string
	GetTestString() string
	GetFood() *string
	GetWalk() func()
	GetTestNilFunc() func()
	GetSubTest() *SubTest
	GetPaths() Paths
	GetTestProtected() []byte
	GetFOO() *FOO
	GetSpecSub() SpecVisitor
	GetTestParamterBool() bool
	GetTestParamterStr() string
}

ConfigVisitor visitor interface for Config

func AtomicConfig

func AtomicConfig() ConfigVisitor

AtomicConfig return atomic *ConfigVisitor

type ETCD added in v1.0.2

type ETCD struct {
	// annotation@Endpoints(comment="etcd地址")
	Endpoints []string `usage:"etcd地址"`
	// annotation@TimeoutsPointer(comment="timeout设置")
	TimeoutsPointer *Timeouts `usage:"timeout设置"`
	// annotation@Redis(getter="RedisVisitor")
	Redis *Redis
	// contains filtered or unexported fields
}

ETCD should use NewETCD to initialize it

func NewETCD added in v1.0.2

func NewETCD(writeTimeout time.Duration, opts ...ETCDOption) *ETCD

NewETCD new ETCD

func (*ETCD) ApplyOption added in v1.0.2

func (cc *ETCD) ApplyOption(opts ...ETCDOption)

ApplyOption apply mutiple new option

func (*ETCD) GetEndpoints added in v1.0.2

func (cc *ETCD) GetEndpoints() []string

all getter func

func (*ETCD) GetRedis added in v1.0.2

func (cc *ETCD) GetRedis() RedisVisitor

func (*ETCD) GetTimeoutsPointer added in v1.0.2

func (cc *ETCD) GetTimeoutsPointer() *Timeouts

func (*ETCD) GetWriteTimeout added in v1.0.2

func (cc *ETCD) GetWriteTimeout() time.Duration

type ETCDInterface added in v1.0.2

type ETCDInterface interface {
	ETCDVisitor
	ApplyOption(...ETCDOption)
}

ETCDInterface visitor + ApplyOption interface for ETCD

type ETCDOption added in v1.0.2

type ETCDOption func(cc *ETCD)

ETCDOption option func

func WithETCDEndpoints added in v1.0.2

func WithETCDEndpoints(v ...string) ETCDOption

WithETCDEndpoints etcd地址

func WithETCDRedis added in v1.0.2

func WithETCDRedis(v *Redis) ETCDOption

WithETCDRedis option func for filed Redis

func WithETCDTimeoutsPointer added in v1.0.2

func WithETCDTimeoutsPointer(v *Timeouts) ETCDOption

WithETCDTimeoutsPointer timeout设置

type ETCDVisitor added in v1.0.2

type ETCDVisitor interface {
	GetEndpoints() []string
	GetTimeoutsPointer() *Timeouts
	GetRedis() RedisVisitor
	GetWriteTimeout() time.Duration
}

ETCDVisitor visitor interface for ETCD

type FOO

type FOO struct {
	Usernames_Passwords map[string]string
}

type Paths added in v1.0.4

type Paths struct {
	Path1 string
	Path2 string
}

type Redis added in v1.0.1

type Redis struct {
	Endpoints      []string `xconf:"endpoints"`
	Cluster        bool     `xconf:"cluster"`
	TimeoutsStruct Timeouts `xconf:"timeouts_struct"`
}

Redis should use NewRedis to initialize it

func NewRedis added in v1.0.1

func NewRedis(opts ...RedisOption) *Redis

NewRedis new Redis

func (*Redis) ApplyOption added in v1.0.1

func (cc *Redis) ApplyOption(opts ...RedisOption) []RedisOption

ApplyOption apply mutiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)

func (*Redis) AtomicSetFunc added in v1.0.1

func (cc *Redis) AtomicSetFunc() func(interface{})

AtomicSetFunc used for XConf

func (*Redis) GetCluster added in v1.0.2

func (cc *Redis) GetCluster() bool

func (*Redis) GetEndpoints added in v1.0.2

func (cc *Redis) GetEndpoints() []string

all getter func

func (*Redis) GetTimeoutsStruct added in v1.0.2

func (cc *Redis) GetTimeoutsStruct() Timeouts

type RedisInterface added in v1.0.1

type RedisInterface interface {
	RedisVisitor
	ApplyOption(...RedisOption) []RedisOption
}

RedisInterface visitor + ApplyOption interface for Redis

type RedisOption added in v1.0.1

type RedisOption func(cc *Redis) RedisOption

RedisOption option func

func WithRedisCluster added in v1.0.2

func WithRedisCluster(v bool) RedisOption

WithRedisCluster option func for filed Cluster

func WithRedisEndpoints added in v1.0.2

func WithRedisEndpoints(v ...string) RedisOption

WithRedisEndpoints option func for filed Endpoints

func WithRedisTimeoutsStruct added in v1.0.2

func WithRedisTimeoutsStruct(v Timeouts) RedisOption

WithRedisTimeoutsStruct option func for filed TimeoutsStruct

type RedisVisitor added in v1.0.1

type RedisVisitor interface {
	GetEndpoints() []string
	GetCluster() bool
	GetTimeoutsStruct() Timeouts
}

RedisVisitor visitor interface for Redis

func AtomicRedis added in v1.0.1

func AtomicRedis() RedisVisitor

AtomicRedis return atomic *RedisVisitor

type SpecInterface

type SpecInterface interface {
	SpecVisitor
	ApplyOption(...SpecOption)
}

SpecInterface visitor + ApplyOption interface for spec

type SpecOption

type SpecOption func(cc *spec)

SpecOption option func

func WithServerTestBool1

func WithServerTestBool1(v bool) SpecOption

WithServerTestBool1 option func for filed TestBool1

func WithServerTestInt1

func WithServerTestInt1(v int) SpecOption

WithServerTestInt1 这里是函数注释3,这里是函数注释4

func WithServerTestNilFunc1

func WithServerTestNilFunc1(v func()) SpecOption

WithServerTestNilFunc1 option func for filed TestNilFunc1

func WithServerTestReserved2Inner1

func WithServerTestReserved2Inner1(v int) SpecOption

WithServerTestReserved2Inner1 option func for filed TestReserved2Inner1

type SpecVisitor

type SpecVisitor interface {
	GetTestNil1() interface{}
	GetTestBool1() bool
	GetTestInt1() int
	GetTestNilFunc1() func()
	GetTestReserved2_() []byte
	GetTestReserved2Inner1() int
}

SpecVisitor visitor interface for spec

func AtomicSpec

func AtomicSpec() SpecVisitor

AtomicSpec return atomic *SpecVisitor

type SubTest

type SubTest struct {
	HTTPAddress string         `xconf:"http_address"`
	MapNotLeaf  map[string]int `xconf:"map_not_leaf,notleaf"`
	Map2        map[string]int `xconf:"map2"`
	Map3        map[string]int `xconf:"map3"`
	Slice2      []int64        `xconf:"slice2"`
}

type Timeouts added in v1.0.2

type Timeouts struct {
	ReadTimeout  time.Duration `xconf:"read_timeout" default:"5s"`
	WriteTimeout time.Duration `xconf:"write_timeout" default:"10s"`
	ConnTimeout  time.Duration `xconf:"conn_timeout" default:"20s"`
}

type WatchError added in v1.0.2

type WatchError = func(loaderName string, confPath string, watchErr error)

type XXXXXX added in v1.0.2

type XXXXXX struct {
	OptionUsage      string            `xconf:"option_usage"`
	Endpoints        []string          `xconf:"endpoints"`
	ReadTimeout      time.Duration     `xconf:"read_timeout"`
	TypeMapIntString map[int]string    `xconf:"type_map_int_string"`
	TypeSliceInt64   []int64           `xconf:"type_slice_int64"`
	TypeBool         bool              `xconf:"type_bool"`
	MapRedis         map[string]*Redis `xconf:"map_redis"`
	// annotation@Redis(getter="RedisVisitor",deprecated="use MapRedis intead")
	Redis              *Redis                                                   `xconf:"redis,deprecated" usage:"Deprecated: use MapRedis intead"` // 辅助指定类型为*Redis
	OnWatchError       WatchError                                               `xconf:"on_watch_error"`                                           // 辅助指定类型为WatchError
	OnWatchErrorNotNil func(loaderName string, confPath string, watchErr error) `xconf:"on_watch_error_not_nil"`
	TypeSliceDuratuon  []time.Duration                                          `xconf:"type_slice_duratuon"` // 辅助指定类型为WatchError
}

XXXXXX should use NewXXXXXX to initialize it

func NewXXXXXX added in v1.0.2

func NewXXXXXX(opts ...XXXXXXOption) *XXXXXX

NewXXXXXX new XXXXXX

func (*XXXXXX) ApplyOption added in v1.0.2

func (cc *XXXXXX) ApplyOption(opts ...XXXXXXOption) []XXXXXXOption

ApplyOption apply mutiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)

func (*XXXXXX) AtomicSetFunc added in v1.0.3

func (cc *XXXXXX) AtomicSetFunc() func(interface{})

AtomicSetFunc used for XConf

func (*XXXXXX) GetEndpoints added in v1.0.2

func (cc *XXXXXX) GetEndpoints() []string

func (*XXXXXX) GetMapRedis added in v1.0.2

func (cc *XXXXXX) GetMapRedis() map[string]*Redis

func (*XXXXXX) GetOnWatchError added in v1.0.2

func (cc *XXXXXX) GetOnWatchError() WatchError

func (*XXXXXX) GetOnWatchErrorNotNil added in v1.0.2

func (cc *XXXXXX) GetOnWatchErrorNotNil() func(loaderName string, confPath string, watchErr error)

func (*XXXXXX) GetOptionUsage added in v1.0.3

func (cc *XXXXXX) GetOptionUsage() string

all getter func

func (*XXXXXX) GetReadTimeout added in v1.0.2

func (cc *XXXXXX) GetReadTimeout() time.Duration

func (*XXXXXX) GetRedis deprecated added in v1.0.2

func (cc *XXXXXX) GetRedis() RedisVisitor

GetRedis visitor func for filed Redis

Deprecated: use MapRedis intead

func (*XXXXXX) GetTypeBool added in v1.0.2

func (cc *XXXXXX) GetTypeBool() bool

func (*XXXXXX) GetTypeMapIntString added in v1.0.2

func (cc *XXXXXX) GetTypeMapIntString() map[int]string

func (*XXXXXX) GetTypeSliceDuratuon added in v1.0.2

func (cc *XXXXXX) GetTypeSliceDuratuon() []time.Duration

func (*XXXXXX) GetTypeSliceInt64 added in v1.0.2

func (cc *XXXXXX) GetTypeSliceInt64() []int64

type XXXXXXInterface added in v1.0.2

type XXXXXXInterface interface {
	XXXXXXVisitor
	ApplyOption(...XXXXXXOption) []XXXXXXOption
}

XXXXXXInterface visitor + ApplyOption interface for XXXXXX

type XXXXXXOption added in v1.0.2

type XXXXXXOption func(cc *XXXXXX) XXXXXXOption

XXXXXXOption option func

func WithXXXXXXEndpoints added in v1.0.2

func WithXXXXXXEndpoints(v ...string) XXXXXXOption

WithXXXXXXEndpoints option func for filed Endpoints

func WithXXXXXXMapRedis added in v1.0.2

func WithXXXXXXMapRedis(v map[string]*Redis) XXXXXXOption

WithXXXXXXMapRedis option func for filed MapRedis

func WithXXXXXXOnWatchError added in v1.0.2

func WithXXXXXXOnWatchError(v WatchError) XXXXXXOption

WithXXXXXXOnWatchError option func for filed OnWatchError

func WithXXXXXXOnWatchErrorNotNil added in v1.0.2

func WithXXXXXXOnWatchErrorNotNil(v func(loaderName string, confPath string, watchErr error)) XXXXXXOption

WithXXXXXXOnWatchErrorNotNil option func for filed OnWatchErrorNotNil

func WithXXXXXXOptionUsage added in v1.0.3

func WithXXXXXXOptionUsage(v string) XXXXXXOption

WithXXXXXXOptionUsage option func for filed OptionUsage

func WithXXXXXXReadTimeout added in v1.0.2

func WithXXXXXXReadTimeout(v time.Duration) XXXXXXOption

WithXXXXXXReadTimeout option func for filed ReadTimeout

func WithXXXXXXRedis deprecated added in v1.0.2

func WithXXXXXXRedis(v *Redis) XXXXXXOption

WithXXXXXXRedis option func for filed Redis

Deprecated: use MapRedis intead

func WithXXXXXXTypeBool added in v1.0.2

func WithXXXXXXTypeBool(v bool) XXXXXXOption

WithXXXXXXTypeBool option func for filed TypeBool

func WithXXXXXXTypeMapIntString added in v1.0.2

func WithXXXXXXTypeMapIntString(v map[int]string) XXXXXXOption

WithXXXXXXTypeMapIntString option func for filed TypeMapIntString

func WithXXXXXXTypeSliceDuratuon added in v1.0.2

func WithXXXXXXTypeSliceDuratuon(v ...time.Duration) XXXXXXOption

WithXXXXXXTypeSliceDuratuon option func for filed TypeSliceDuratuon

func WithXXXXXXTypeSliceInt64 added in v1.0.2

func WithXXXXXXTypeSliceInt64(v ...int64) XXXXXXOption

WithXXXXXXTypeSliceInt64 option func for filed TypeSliceInt64

type XXXXXXVisitor added in v1.0.2

type XXXXXXVisitor interface {
	GetOptionUsage() string
	GetEndpoints() []string
	GetReadTimeout() time.Duration
	GetTypeMapIntString() map[int]string
	GetTypeSliceInt64() []int64
	GetTypeBool() bool
	GetMapRedis() map[string]*Redis
	// GetRedis visitor func for filed Redis
	//
	// Deprecated: use MapRedis intead
	GetRedis() RedisVisitor
	GetOnWatchError() WatchError
	GetOnWatchErrorNotNil() func(loaderName string, confPath string, watchErr error)
	GetTypeSliceDuratuon() []time.Duration
}

XXXXXXVisitor visitor interface for XXXXXX

func AtomicXXXXXX added in v1.0.3

func AtomicXXXXXX() XXXXXXVisitor

AtomicXXXXXX return atomic *XXXXXXVisitor

Jump to

Keyboard shortcuts

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