Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1691)

Delta Between Two Patch Sets: state/machine.go

Issue 6564054: state: make Refresh return NotFoundError
Left Patch Set: Created 11 years, 6 months ago
Right Patch Set: state: make Refresh return NotFoundError Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « state/charm_test.go ('k') | state/machine_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package state 1 package state
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "labix.org/v2/mgo" 5 "labix.org/v2/mgo"
6 "labix.org/v2/mgo/txn" 6 "labix.org/v2/mgo/txn"
7 "launchpad.net/juju-core/state/presence" 7 "launchpad.net/juju-core/state/presence"
8 "launchpad.net/juju-core/trivial" 8 "launchpad.net/juju-core/trivial"
9 "strconv" 9 "strconv"
10 "time" 10 "time"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // It does nothing otherwise. 89 // It does nothing otherwise.
90 func (m *Machine) EnsureDead() error { 90 func (m *Machine) EnsureDead() error {
91 err := ensureDead(m.st, m.st.machines, m.doc.Id, "machine", nil, "") 91 err := ensureDead(m.st, m.st.machines, m.doc.Id, "machine", nil, "")
92 if err != nil { 92 if err != nil {
93 return err 93 return err
94 } 94 }
95 m.doc.Life = Dead 95 m.doc.Life = Dead
96 return nil 96 return nil
97 } 97 }
98 98
99 // Refresh reads the contents of the Machine from the underlying 99 // Refresh refreshes the contents of the machine from the underlying
100 // state. It returns a NotFoundError if the machine has been removed. 100 // state. It returns a NotFoundError if the machine has been removed.
101 func (m *Machine) Refresh() error { 101 func (m *Machine) Refresh() error {
102 doc := machineDoc{} 102 doc := machineDoc{}
103 err := m.st.machines.FindId(m.doc.Id).One(&doc) 103 err := m.st.machines.FindId(m.doc.Id).One(&doc)
104 if err == mgo.ErrNotFound { 104 if err == mgo.ErrNotFound {
105 return notFound("machine %v", m) 105 return notFound("machine %v", m)
106 } 106 }
107 if err != nil { 107 if err != nil {
108 return fmt.Errorf("cannot refresh machine %v: %v", m, err) 108 return fmt.Errorf("cannot refresh machine %v: %v", m, err)
109 } 109 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return fmt.Errorf("cannot set instance id of machine %s: %v", m, onAbort(err, errNotAlive)) 195 return fmt.Errorf("cannot set instance id of machine %s: %v", m, onAbort(err, errNotAlive))
196 } 196 }
197 m.doc.InstanceId = id 197 m.doc.InstanceId = id
198 return nil 198 return nil
199 } 199 }
200 200
201 // String returns a unique description of this machine. 201 // String returns a unique description of this machine.
202 func (m *Machine) String() string { 202 func (m *Machine) String() string {
203 return strconv.Itoa(m.doc.Id) 203 return strconv.Itoa(m.doc.Id)
204 } 204 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b