Documentation
¶
Index ¶
Constants ¶
const ( // NIL represents a nil watcher, which will watch nothing NIL = "nil" // CONFIG represents a config watcher, watch /lain/config CONFIG = "config" // PODGROUP represents a podgroup watcher, watch /lain/deployd/pod_groups PODGROUP = "podgroup" // DEPENDS represents a depends watcher, watch /lain/deployd/depends DEPENDS = "depends" // NODES represents a node watcher, it's based on podgroup watcher NODES = "nodes" // CONTAINER represents a container watcher, it's based on podgroup watcher CONTAINER = "container" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cacher ¶
Cacher is a simple cache, used to cache converted data from store
func (*Cacher) Delete ¶
Delete delete the key in cache, if recursive is true, all the keys having `key` prefix will be deleted
func (*Cacher) Get ¶
Get find the values in cache, if key was found, return the map with only one key; or it will return all the KV data which key has `key` prefix
type ConvertFunc ¶
ConvertFunc convert the data from store into a general type
type Event ¶
type Event struct {
// ID is a event id, it is cumulative when you get a new event
ID uint64
// Action is the event type, init, update, delete or error
Action store.Action
// Data is event data, it always return the newest data, no matter what the action is
Data map[string]interface{}
}
Event represents a watcher event
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver represents a receiver of sender, which can receive data from sender
type Sender ¶
Sender having a cache, when the data in cache changed, call Broadcast() sending new data to receivers.
type Watcher ¶
type Watcher struct {
Store store.Store
Ctx context.Context
*Sender
// contains filtered or unexported fields
}
Watcher having a sender, store, and convert function. It read and watch data from store, and use convert() to convert, then use sender to cache data and broadcast the event.
func New ¶
func New(s store.Store, ctx context.Context, key string, convert ConvertFunc, ckey2skey func(string) string) (*Watcher, error)
New create a new watcher
func (*Watcher) Get ¶
Get function get the newest data for keys having `prefix` prefix. it returned error only when key is empty. it return all the data when prefix is '*'