blob: 92aa45955567370fc3a240d41d91346bfc230786 [file] [log] [blame]
David Why Use Two When One Will Do Presotto7034d3b2014-05-30 17:08:46 -07001package config
2
3// ConfigService exists to get things going when you plug a device into a network.
4// Anything that we currently pass to apps as environment variables (proxy server,
5// global name server, ...) should come from here.
6
7// Both keys and values can have embedded white space but they can't start
8// or end with whitespace. keys cannot include ':'s.
9
10type Pair struct {
11 Key string
12 Value string
13 Nonexistant bool
14}
15
16type ConfigService interface {
17 // Stop stops a config service.
18 Stop()
19
20 // Get returns the value associated with name or an error if no value exists
21 // or can be determined.
22 Get(name string) (string, error)
23
24 // GetAll returns all attribute/value pairs as a map or an error if no config
25 // can be found.
26 GetAll() (map[string]string, error)
27
28 // Watch returns a stream of values for a particuar key.
29 Watch(key string) chan Pair
30
31 // Watch returns a stream key, value pairs.
32 WatchAll() chan Pair
33
34 // Reread the config info (for example, from a file). In particular
35 // this says nothing about where the config resides or how it is read.
36 Reread() error
37}