LEFT | RIGHT |
(no file at all) | |
1 // launchpad.net/juju/state | 1 // launchpad.net/juju/state |
2 // | 2 // |
3 // Copyright (c) 2011-2012 Canonical Ltd. | 3 // Copyright (c) 2011-2012 Canonical Ltd. |
4 | 4 |
5 package state | 5 package state |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "launchpad.net/goyaml" | 10 "launchpad.net/goyaml" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return err | 229 return err |
230 } | 230 } |
231 return nil | 231 return nil |
232 } | 232 } |
233 | 233 |
234 // Config returns the configuration node for the service. | 234 // Config returns the configuration node for the service. |
235 func (s *Service) Config() (*ConfigNode, error) { | 235 func (s *Service) Config() (*ConfigNode, error) { |
236 return readConfigNode(s.st.zk, s.zkConfigPath()) | 236 return readConfigNode(s.st.zk, s.zkConfigPath()) |
237 } | 237 } |
238 | 238 |
| 239 // WatchConfig creates a watcher for the configuration node |
| 240 // of the service. |
| 241 func (s *Service) WatchConfig() *ConfigWatcher { |
| 242 return newConfigWatcher(s.st, s.zkConfigPath()) |
| 243 } |
| 244 |
239 // zkKey returns ZooKeeper key of the service. | 245 // zkKey returns ZooKeeper key of the service. |
240 func (s *Service) zkKey() string { | 246 func (s *Service) zkKey() string { |
241 return s.key | 247 return s.key |
242 } | 248 } |
243 | 249 |
244 // zkPath returns the ZooKeeper base path for the service. | 250 // zkPath returns the ZooKeeper base path for the service. |
245 func (s *Service) zkPath() string { | 251 func (s *Service) zkPath() string { |
246 return fmt.Sprintf("/services/%s", s.key) | 252 return fmt.Sprintf("/services/%s", s.key) |
247 } | 253 } |
248 | 254 |
249 // zkConfigPath returns the ZooKeeper path for the service configuration. | 255 // zkConfigPath returns the ZooKeeper path for the service configuration. |
250 func (s *Service) zkConfigPath() string { | 256 func (s *Service) zkConfigPath() string { |
251 return fmt.Sprintf("/services/%s/config", s.key) | 257 return fmt.Sprintf("/services/%s/config", s.key) |
252 } | 258 } |
253 | 259 |
254 // zkExposedPath, if exists in ZooKeeper, indicates, that a | 260 // zkExposedPath, if exists in ZooKeeper, indicates, that a |
255 // service is exposed. | 261 // service is exposed. |
256 func (s *Service) zkExposedPath() string { | 262 func (s *Service) zkExposedPath() string { |
257 return fmt.Sprintf("/services/%s/exposed", s.key) | 263 return fmt.Sprintf("/services/%s/exposed", s.key) |
258 } | 264 } |
LEFT | RIGHT |