Documentation ¶
Index ¶
- Constants
- Variables
- func Cleanup()
- func GetConfigByKey(key string) (string, error)
- func GetConfigCacheMap() map[string]string
- func GetNamespaceList() []string
- func Init(opts ...Option) (err error)
- func RegChangeEventHandler(in CHandler)
- func Start()
- func StartContext(ctx context.Context)
- type CHandler
- type ChangeEvent
- type ConfigChange
- type ConfigChangeType
- type ConfigReader
- type Option
- func IgnoreNameSpace() Option
- func WithApolloAddr(s string) Option
- func WithAppId(s string) Option
- func WithBackupDir(s string) Option
- func WithBackupSuffix(s string) Option
- func WithCacheSize(v int) Option
- func WithClientIp(v string) Option
- func WithCluster(s string) Option
- func WithConfFile(s string) Option
- func WithConnectTimeout(v time.Duration) Option
- func WithDefaultVals(val map[string]interface{}, namespaceName string) Option
- func WithLogFunc(logDebug, logInfo, logError logger.LogFunc) Option
- func WithLongPollInterval(v time.Duration) Option
- func WithNamespaceName(s string) Option
- func WithNotifyTimeout(v time.Duration) Option
- func WithQuickInitWithBK() Option
- func WithRefreshInterval(v time.Duration) Option
- func WithRetryInterval(v time.Duration) Option
Constants ¶
View Source
const ( // default apollo config file DEFAULT_CONFFILE = "app.properties" // default backup directory DEFAULT_BACKUPDIR = "." // default backup file suffix DEFAULT_BACKUPSUFFIX = ".apollo.json" // default cache size DEFAULT_CONFIGCACHESIZE = 50 * 1024 * 1024 // default namespace DEFAULT_NAMESPACENAME = "application" // default cluster DEFAULT_CLUSTER = "default" // default notify timeout, see apollo notifications DEFAULT_NOTIFYTIMEOUT = 65 * time.Second // default connect timeout DEFAULT_CONNECTTIMEOUT = 10 * time.Second // default retry interval DEFAULT_RETRYINTERVAL = 3 * time.Second )
View Source
const ( EMPTY = "" SEP = "." )
exported constants
View Source
const (
DEFAULT_NOFICATION_ID = -1
)
Variables ¶
View Source
var ( DEFAULT_REFRESHINTERVAL = 5 * time.Minute DEFAULT_LONGPOLLINTERVAL = 5 * time.Second )
Functions ¶
func GetConfigByKey ¶
func GetConfigCacheMap ¶
func RegChangeEventHandler ¶
func RegChangeEventHandler(in CHandler)
RegChangeEventHandler register a config change handler on agollo
Types ¶
type CHandler ¶
type CHandler func(event *ChangeEvent) error
CHandler calls a handler to process config change event
type ChangeEvent ¶
type ChangeEvent struct { Namespace string Changes []*ConfigChange }
ChangeEvent is event of cofig change
type ConfigChange ¶
type ConfigChange struct { Key string OldValue string NewValue string ChangeType ConfigChangeType }
ConfigChange contains config change info
type ConfigChangeType ¶
type ConfigChangeType int
ConfigChangeType specifies the type of a certain config
const ( ADDED ConfigChangeType = iota MODIFIED DELETED )
Config change types: add, modified, deleted
type ConfigReader ¶
type ConfigReader interface { GetStringValue(key string) (string, error) GetIntValue(key string) (int, error) GetFloatValue(key string) (float64, error) GetBoolValue(key string) (bool, error) GetBytesValue(key string) ([]byte, error) }
ConfigReader gets type-specified value
func GetConfigReader ¶
func GetConfigReader(namespaceName string) ConfigReader
GetConfigReader returns a reader that can read config values
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option contains apply method to load options
func IgnoreNameSpace ¶ added in v0.3.0
func IgnoreNameSpace() Option
func WithCluster ¶
func WithConnectTimeout ¶
set apollo config connect timeout
func WithDefaultVals ¶
set key's default value for example:
WithDefaultVals(map[string]interface{}{ "key1": "11", }, "application") when call GetStringValue("key1"), if config key1 not found, return 11 NOTE: default value is bound to type, if call GetIntValue("key1") will return 0 NOTE: default value's type is in int/string/bool/float64, will panic when use other types
func WithLogFunc ¶
func WithLongPollInterval ¶
set long poll interval
func WithNamespaceName ¶
set namespace list, use , to separate each namespace
func WithQuickInitWithBK ¶
func WithQuickInitWithBK() Option
get config from backup file when call Init function
Source Files ¶
Click to show internal directories.
Click to hide internal directories.