Documentation
¶
Index ¶
- Variables
- func GetAllKeys(opts ...OpOption) []string
- func GetContent(opts ...OpOption) string
- func GetPropertiesContent(opts ...OpOption) string
- func GetReleaseKey(opts ...OpOption) string
- func GetString(key string, opts ...OpOption) string
- func OnUpdate(handler func(*ChangeEvent))
- func Stop() error
- func SubscribeToNamespaces(namespaces ...string) error
- type Change
- type ChangeEvent
- type ChangeType
- type Client
- type ClientOption
- type Conf
- type Logger
- type OpOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorStatusNotOK = errors.New("http resp code not ok")
Functions ¶
func GetAllKeys ¶
GetAllKeys return all config keys in given namespace
func GetContent ¶
GetNameSpaceContent get contents of namespace
func GetPropertiesContent ¶
GetPropertiesContent for properties namespace
func GetReleaseKey ¶
GetReleaseKey return release key for namespace
func SubscribeToNamespaces ¶
SubscribeToNamespaces fetch namespace config to local and subscribe to updates
Types ¶
type Change ¶
type Change struct {
Key string
OldValue string
NewValue string
ChangeType ChangeType
}
Change represent a single key change
type ChangeEvent ¶
ChangeEvent change event
func (*ChangeEvent) String ¶
func (e *ChangeEvent) String() string
type ChangeType ¶
type ChangeType int
ChangeType for a key
const ( // ADD a new value ADD ChangeType = iota // MODIFY a old value MODIFY // DELETE ... DELETE )
func (ChangeType) String ¶
func (c ChangeType) String() string
type Client ¶
type Client interface {
// Start fetch all config to local cache and run period poll to keep update to remote server
Start() error
// Stop period poll
Stop() error
OnUpdate(func(*ChangeEvent))
// Get string value for key
GetString(key string, opts ...OpOption) string
// GetContent for namespace
GetContent(opts ...OpOption) string
// GetPropertiesContent for properties namespace
GetPropertiesContent(opts ...OpOption) string
// GetAllKeys return all keys
GetAllKeys(opts ...OpOption) []string
// GetReleaseKey return release key for namespace
GetReleaseKey(opts ...OpOption) string
// SubscribeToNamespaces will subscribe to new namespace and keep update
SubscribeToNamespaces(namespaces ...string) error
}
func NewClient ¶
func NewClient(conf *Conf, opts ...ClientOption) Client
NewClient create client from conf
type ClientOption ¶
type ClientOption func(*client)
func SkipLocalCache ¶
func SkipLocalCache() ClientOption
type Conf ¶
type Conf struct {
AppID string `json:"app_id"`
Cluster string `json:"cluster,omitempty"`
NameSpaceNames []string `json:"namespace_names,omitempty"`
CacheDir string `json:"cache_dir,omitempty"`
MetaAddr string `json:"meta_addr,omitempty"`
AccesskeySecret string `json:"accesskey_secret,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
Retry int `json:"retry,omitempty"` // retry count. 0 means no retry
SyncTimeout int64 `json:"sync_timeout,omitempty"` // sync request timeout, unit:ms
PollTimeout int64 `json:"poll_timeout,omitempty"` // poll request timeout, unit:ms
}
Conf ...
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
properties
Package properties is used to read or write or modify the properties document.
|
Package properties is used to read or write or modify the properties document. |
Click to show internal directories.
Click to hide internal directories.