1
// Copyright 2012, 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"launchpad.net/juju-core/state/api/params"
12
// Life represents the lifecycle state of the entities
13
// Relation, Unit, Service and Machine.
23
var lifeStrings = [nLife]params.Life{
29
func (l Life) String() string {
30
return string(lifeStrings[l])
33
var isAliveDoc = D{{"life", Alive}}
34
var isDeadDoc = D{{"life", Dead}}
35
var notDeadDoc = D{{"life", D{{"$ne", Dead}}}}
37
// Living describes state entities with a lifecycle.
38
type Living interface {
45
func isAlive(coll *mgo.Collection, id interface{}) (bool, error) {
46
n, err := coll.Find(D{{"_id", id}, {"life", Alive}}).Count()
50
func isNotDead(coll *mgo.Collection, id interface{}) (bool, error) {
51
n, err := coll.Find(D{{"_id", id}, {"life", D{{"$ne", Dead}}}}).Count()