Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned by GetMount when an object does not exist.
Functions ¶
func NewDecoder ¶
func NewDecoder(w WatchableConfig) watcher.Watchable
NewDecoder decodes mount protobufs and converts a WatchableConfig to a watcher.Watchable.
func WatchConfig ¶
func WatchConfig(ctx context.Context, cli *clientv3.Client, target WatchableConfig) (<-chan struct{}, <-chan struct{})
WatchConfig monitors a WatchableConfig object and keeps it in sync with etcd. The outer Context is used for termination. Returns the WaitForInit() and Notify() channels so the client can know when the configuration is bootstrapped and changes.
The simplest, read-only configuration management looks like this:
var config client.MountConfig ready, _ := client.WatchConfig(ctx, etcdClient, &config) <-ready
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
The Client manipulates the autoradio stream configuration by talking directly to etcd.
func (*Client) DeleteMount ¶
DeleteMount deletes a mountpoint.
func (*Client) ListMounts ¶
ListMounts returns a list of all mountpoints.
type MountConfig ¶
type MountConfig struct {
// contains filtered or unexported fields
}
MountConfig is a container of mountpoints, representing the entirety of the autoradio database-backed configuration. It implements the WatchableConfig interface.
func (*MountConfig) Delete ¶
func (mc *MountConfig) Delete(path string)
Delete a mount. Implements the WatchableConfig interface.
func (*MountConfig) GetMount ¶
func (mc *MountConfig) GetMount(path string) (*pb.Mount, bool)
GetMount returns a specific mount, with map-like semantics.
func (*MountConfig) GetMounts ¶
func (mc *MountConfig) GetMounts() []*pb.Mount
GetMounts returns the list of all mounts.
func (*MountConfig) Reset ¶
func (mc *MountConfig) Reset(mounts map[string]*pb.Mount)
Reset the container with new values. Implements the WatchableConfig interface.
func (*MountConfig) Set ¶
func (mc *MountConfig) Set(m *pb.Mount)
Set a new mount config or update an existing one. Implements the WatchableConfig interface.
type WatchableConfig ¶
WatchableConfig mimics the watcher.Watchable interface, but with the decoded protobufs. This allows injecting middleware to the configuration state management, to implement custom notification protocols.