Left: | ||
Right: |
OLD | NEW |
---|---|
1 package mstate | 1 package mstate |
2 | 2 |
3 import ( | 3 import ( |
4 "errors" | 4 "errors" |
5 "fmt" | 5 "fmt" |
6 "labix.org/v2/mgo" | 6 "labix.org/v2/mgo" |
7 "labix.org/v2/mgo/bson" | 7 "labix.org/v2/mgo/bson" |
8 "launchpad.net/juju-core/charm" | 8 "launchpad.net/juju-core/charm" |
9 "launchpad.net/juju-core/trivial" | 9 "launchpad.net/juju-core/trivial" |
10 "strconv" | 10 "strconv" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 Life Life | 23 Life Life |
24 UnitSeq int | 24 UnitSeq int |
25 Exposed bool | 25 Exposed bool |
26 } | 26 } |
27 | 27 |
28 // Name returns the service name. | 28 // Name returns the service name. |
29 func (s *Service) Name() string { | 29 func (s *Service) Name() string { |
30 return s.doc.Name | 30 return s.doc.Name |
31 } | 31 } |
32 | 32 |
33 // Life returns whether the service is Alive, Dying or Dead. | |
34 func (s *Service) Life() Life { | |
35 return s.doc.Life | |
36 } | |
37 | |
38 // Kill sets the service lifecycle to Dying if it is Alive. | |
39 // It does nothing otherwise. | |
40 func (s *Service) Kill() error { | |
41 err := ensureLife(s.doc.Name, s.st.services, "service", Dying) | |
42 if err != nil { | |
43 return err | |
44 } | |
45 s.doc.Life = Dying | |
niemeyer
2012/08/28 13:48:59
As discussed on IRC, we'll need to fix the Kill me
TheMue
2012/08/28 14:50:11
Yep, will get an extra CL.
| |
46 return nil | |
47 } | |
48 | |
49 // Die sets the service lifecycle to Dead if it is Alive or Dying. | |
50 // It does nothing otherwise. | |
51 func (s *Service) Die() error { | |
52 err := ensureLife(s.doc.Name, s.st.services, "service", Dead) | |
53 if err != nil { | |
54 return err | |
55 } | |
56 s.doc.Life = Dead | |
57 return nil | |
58 } | |
59 | |
33 // IsExposed returns whether this service is exposed. The explicitly open | 60 // IsExposed returns whether this service is exposed. The explicitly open |
34 // ports (with open-port) for exposed services may be accessed from machines | 61 // ports (with open-port) for exposed services may be accessed from machines |
35 // outside of the local deployment network. See SetExposed and ClearExposed. | 62 // outside of the local deployment network. See SetExposed and ClearExposed. |
36 func (s *Service) IsExposed() (bool, error) { | 63 func (s *Service) IsExposed() (bool, error) { |
37 return s.doc.Exposed, nil | 64 return s.doc.Exposed, nil |
38 } | 65 } |
39 | 66 |
40 // CharmURL returns the charm URL this service is supposed to use. | 67 // CharmURL returns the charm URL this service is supposed to use. |
41 func (s *Service) CharmURL() (url *charm.URL, err error) { | 68 func (s *Service) CharmURL() (url *charm.URL, err error) { |
42 return s.doc.CharmURL, nil | 69 return s.doc.CharmURL, nil |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 docs := []relationDoc{} | 254 docs := []relationDoc{} |
228 err = s.st.relations.Find(sel).All(&docs) | 255 err = s.st.relations.Find(sel).All(&docs) |
229 if err != nil { | 256 if err != nil { |
230 return nil, err | 257 return nil, err |
231 } | 258 } |
232 for _, v := range docs { | 259 for _, v := range docs { |
233 relations = append(relations, newRelation(s.st, &v)) | 260 relations = append(relations, newRelation(s.st, &v)) |
234 } | 261 } |
235 return relations, nil | 262 return relations, nil |
236 } | 263 } |
OLD | NEW |