Documentation ¶
Overview ¶
Package archaius provides you APIs which helps to manage files, remote config center configurations
Index ¶
- Constants
- func AddDimensionInfo(labels map[string]string) (map[string]string, error)
- func AddFile(file string, opts ...FileOption) error
- func AddSource(source source.ConfigSource) error
- func Clean() error
- func CustomInit(sources ...source.ConfigSource) error
- func Delete(key string) error
- func EnableRemoteSource(remoteSource string, ci *RemoteInfo) error
- func Exist(key string) bool
- func Get(key string) interface{}
- func GetBool(key string, defaultValue bool) bool
- func GetConfigs() map[string]interface{}
- func GetConfigsWithSourceNames() map[string]interface{}
- func GetFloat64(key string, defaultValue float64) float64
- func GetInt(key string, defaultValue int) int
- func GetInt64(key string, defaultValue int64) int64
- func GetString(key string, defaultValue string) string
- func GetValue(key string) cast.Value
- func Init(opts ...Option) error
- func InstallRemoteSource(source string, remoteSource NewRemoteSource)
- func RegisterListener(listenerObj event.Listener, key ...string) error
- func RegisterModuleListener(listenerObj event.ModuleListener, prefix ...string) error
- func Set(key string, value interface{}) error
- func UnRegisterListener(listenerObj event.Listener, key ...string) error
- func UnRegisterModuleListener(listenerObj event.ModuleListener, prefix ...string) error
- func UnmarshalConfig(obj interface{}) error
- func WriteTo(w io.Writer) error
- type FileOption
- type FileOptions
- type NewRemoteSource
- type Option
- func WithCommandLineSource() Option
- func WithDefaultFileHandler(handler util.FileHandler) Option
- func WithENVSource() Option
- func WithMemorySource() Option
- func WithOptionalFiles(f []string) Option
- func WithRemoteSource(provider string, ri *RemoteInfo) Option
- func WithRequiredFiles(f []string) Option
- type Options
- type RemoteInfo
Constants ¶
const ( // ApolloSource is for apollo source ApolloSource = "apollo" // ConfigCenterSource is for config center source ConfigCenterSource = "config-center" // KieSource is for ServiceComb-Kie source KieSource = "kie" )
Variables ¶
This section is empty.
Functions ¶
func AddDimensionInfo ¶ added in v0.21.0
AddDimensionInfo adds a NewDimensionInfo of which configurations needs to be taken
func AddFile ¶
func AddFile(file string, opts ...FileOption) error
AddFile is for to add the configuration files at runtime
func AddSource ¶
func AddSource(source source.ConfigSource) error
AddSource add source implementation
func Clean ¶ added in v0.15.0
func Clean() error
Clean will call config manager CleanUp Method, it deletes all sources which means all of key value is deleted. after you call Clean, you can init archaius again
func CustomInit ¶ added in v0.13.0
func CustomInit(sources ...source.ConfigSource) error
CustomInit accept a list of config source, add it into archaius runtime. it almost like Init(), but you can fully control config sources you inject to archaius
func EnableRemoteSource ¶ added in v0.21.0
func EnableRemoteSource(remoteSource string, ci *RemoteInfo) error
EnableRemoteSource create a remote source singleton A config center source pull remote config server key values into local memory so that you can use GetXXX to get value easily
func GetConfigs ¶
func GetConfigs() map[string]interface{}
GetConfigs gives the information about all configurations
func GetConfigsWithSourceNames ¶ added in v1.5.0
func GetConfigsWithSourceNames() map[string]interface{}
GetConfigsWithSourceNames gives the information about all configurations each config key, along with its source will be returned the returned map will be like:
map[string]interface{}{ key string: map[string]interface{"value": value, "sourceName": sourceName} }
func GetFloat64 ¶
GetFloat64 gives the key value in the form of float64
func InstallRemoteSource ¶ added in v1.1.0
func InstallRemoteSource(source string, remoteSource NewRemoteSource)
InstallRemoteSource allow user customize remote source
func RegisterListener ¶
RegisterListener to Register all listener for different key changes, each key could be a regular expression
func RegisterModuleListener ¶ added in v1.3.0
func RegisterModuleListener(listenerObj event.ModuleListener, prefix ...string) error
RegisterModuleListener to Register all moduleListener for different key(prefix) changes
func Set ¶ added in v0.21.0
Set add the configuration key, value pairs into memory source at runtime it is just affect the local configs
func UnRegisterListener ¶
UnRegisterListener is to remove the listener
func UnRegisterModuleListener ¶ added in v1.3.0
func UnRegisterModuleListener(listenerObj event.ModuleListener, prefix ...string) error
UnRegisterModuleListener is to remove the moduleListener
func UnmarshalConfig ¶
func UnmarshalConfig(obj interface{}) error
UnmarshalConfig unmarshal the config of receiving object
Types ¶
type FileOption ¶
type FileOption func(options *FileOptions)
FileOption is a func
func WithFileHandler ¶
func WithFileHandler(h util.FileHandler) FileOption
WithFileHandler use custom handler
type FileOptions ¶
type FileOptions struct {
Handler util.FileHandler
}
FileOptions for AddFile func
type NewRemoteSource ¶ added in v1.1.0
type NewRemoteSource func(info *RemoteInfo) (source.ConfigSource, error)
NewRemoteSource create a new remote source
type Option ¶
type Option func(options *Options)
Option is a func
func WithCommandLineSource ¶
func WithCommandLineSource() Option
WithCommandLineSource enable cmd line source archaius will read command line params as key value
func WithDefaultFileHandler ¶
func WithDefaultFileHandler(handler util.FileHandler) Option
WithDefaultFileHandler let user custom handler you can decide how to convert file into kv pairs
func WithENVSource ¶
func WithENVSource() Option
WithENVSource enable env source archaius will read ENV as key value
func WithMemorySource ¶
func WithMemorySource() Option
WithMemorySource accept the information for initiating a Memory source
func WithOptionalFiles ¶
WithOptionalFiles tell archaius to manage files, if not exist will NOT return error
func WithRemoteSource ¶ added in v0.21.0
func WithRemoteSource(provider string, ri *RemoteInfo) Option
WithRemoteSource accept the information for initiating a remote source
func WithRequiredFiles ¶
WithRequiredFiles tell archaius to manage files, if not exist will return error
type Options ¶
type Options struct { RequiredFiles []string OptionalFiles []string FileHandler util.FileHandler RemoteInfo *RemoteInfo RemoteSource string UseCLISource bool UseENVSource bool UseMemSource bool }
Options hold options
type RemoteInfo ¶ added in v0.21.0
type RemoteInfo struct { //required. //Key value can be in different namespace, we call it dimension. //although key is same but in different dimension, the value is different. //you must specify the service,app and version, so that the remote source will pull key value DefaultDimension map[string]string //archaius config center source support 2 types of refresh mechanism: //0: Web-Socket Based - client makes an web socket connection with //the config server and keeps getting an events whenever any data changes. //1: Pull Configuration interval- In this type client keeps polling the configuration from //the config server at regular intervals. RefreshMode int //Pull Configuration interval, unit is second RefreshInterval int //currentConfig for config client implementation //if you already create a client, don't need to set those config URL string TenantName string EnableSSL bool TLSConfig *tls.Config AutoDiscovery bool APIVersion string RefreshPort string ProjectID string }
RemoteInfo has attribute for config center source initialization
Directories ¶
Path | Synopsis |
---|---|
Package event provides the different Listeners
|
Package event provides the different Listeners |
examples
|
|
pkg
|
|
cast
Package cast provides the typeCasting of an object
|
Package cast provides the typeCasting of an object |
serializers
Package serializers created on 2017/6/22.
|
Package serializers created on 2017/6/22. |
serializers/json
Package json is used for marshalling and unmarshalling
|
Package json is used for marshalling and unmarshalling |
Package source manage all the config source and merge configs by precedence
|
Package source manage all the config source and merge configs by precedence |
cli
Package cli created on 2017/6/22.
|
Package cli created on 2017/6/22. |
env
Package env created on 2017/6/22.
|
Package env created on 2017/6/22. |
file
Package filesource created on 2017/6/22.
|
Package filesource created on 2017/6/22. |