1
// launchpad.net/juju/state
3
// Copyright (c) 2011 Canonical Ltd.
7
// --------------------
9
// --------------------
15
// --------------------
17
// --------------------
19
// Service represents the state of one service and
20
// provides also the access to the subordinate parts.
27
func newService(t *topology, id, name string) *Service {
28
return &Service{t, id, name}
31
// Id returns the service id.
32
func (s Service) Id() string {
36
// Name returns the service name.
37
func (s Service) Name() string {
41
// CharmId returns the charm id this service is supposed to use.
42
func (s Service) CharmId() string {
43
cid, err := s.topology.getString(s.zookeeperPath() + "/charm")
46
// TODO: Ouch! Error handling.
47
panic("TODO: Error handling!")
53
// zookeeperPath returns the path within ZooKeeper.
54
func (s Service) zookeeperPath() string {
55
return fmt.Sprintf("/services/%s", s.id)
58
// configPath returns the ZooKeeper path to the configuration.
59
func (s Service) configPath() string {
60
return fmt.Sprintf("%s/config", s.zookeeperPath())
63
// exposedPath, if exists in ZooKeeper, indicates, that a
64
// service is exposed.
65
func (s Service) exposedPath() string {
66
return fmt.Sprintf("/services/%s/exposed", s.id)