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

Side by Side Diff: worker/uniter/filter.go

Issue 10180043: state: Unit.WatchConfigSettings
Patch Set: state: Unit.WatchConfigSettings Created 10 years, 9 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:
View unified diff | Download patch
« no previous file with comments | « state/watcher.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package uniter 4 package uniter
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "launchpad.net/juju-core/charm" 8 "launchpad.net/juju-core/charm"
9 "launchpad.net/juju-core/errors" 9 "launchpad.net/juju-core/errors"
10 "launchpad.net/juju-core/log" 10 "launchpad.net/juju-core/log"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 if err = f.serviceChanged(); err != nil { 216 if err = f.serviceChanged(); err != nil {
217 return err 217 return err
218 } 218 }
219 unitw := f.unit.Watch() 219 unitw := f.unit.Watch()
220 defer watcher.Stop(unitw, &f.tomb) 220 defer watcher.Stop(unitw, &f.tomb)
221 servicew := f.service.Watch() 221 servicew := f.service.Watch()
222 defer watcher.Stop(servicew, &f.tomb) 222 defer watcher.Stop(servicew, &f.tomb)
223 // configw and relationsw can get restarted, so we need to use 223 // configw and relationsw can get restarted, so we need to use
224 // their eventual values in the defer calls. 224 // their eventual values in the defer calls.
225 » var configw *state.ConfigWatcher 225 » var configw *state.EntityWatcher
226 » var configChanges <-chan *state.Settings 226 » var configChanges <-chan struct{}
227 if curl, ok := f.unit.CharmURL(); ok { 227 if curl, ok := f.unit.CharmURL(); ok {
228 » » configw, err = f.unit.WatchServiceConfig() 228 » » configw, err = f.unit.WatchConfigSettings()
229 if err != nil { 229 if err != nil {
230 return err 230 return err
231 } 231 }
232 configChanges = configw.Changes() 232 configChanges = configw.Changes()
233 f.upgradeFrom.url = curl 233 f.upgradeFrom.url = curl
234 } 234 }
235 defer func() { 235 defer func() {
236 if configw != nil { 236 if configw != nil {
237 watcher.Stop(configw, &f.tomb) 237 watcher.Stop(configw, &f.tomb)
238 } 238 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 if err := f.unit.SetCharmURL(curl); err != nil { 311 if err := f.unit.SetCharmURL(curl); err != nil {
312 log.Debugf("worker/uniter/filter: failed setting charm url %q: %v", curl, err) 312 log.Debugf("worker/uniter/filter: failed setting charm url %q: %v", curl, err)
313 return err 313 return err
314 } 314 }
315 select { 315 select {
316 case <-f.tomb.Dying(): 316 case <-f.tomb.Dying():
317 return tomb.ErrDying 317 return tomb.ErrDying
318 case f.charmChanged <- nothing: 318 case f.charmChanged <- nothing:
319 } 319 }
320 » » » configw, err = f.unit.WatchServiceConfig() 320 » » » configw, err = f.unit.WatchConfigSettings()
321 if err != nil { 321 if err != nil {
322 return err 322 return err
323 } 323 }
324 configChanges = configw.Changes() 324 configChanges = configw.Changes()
325 325
326 // Restart the relations watcher. 326 // Restart the relations watcher.
327 if err := relationsw.Stop(); err != nil { 327 if err := relationsw.Stop(); err != nil {
328 return err 328 return err
329 } 329 }
330 relationsw = f.service.WatchRelations() 330 relationsw = f.service.WatchRelations()
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 449
450 // serviceCharm holds information about a charm. 450 // serviceCharm holds information about a charm.
451 type serviceCharm struct { 451 type serviceCharm struct {
452 url *charm.URL 452 url *charm.URL
453 force bool 453 force bool
454 } 454 }
455 455
456 // nothing is marginally more pleasant to read than "struct{}{}". 456 // nothing is marginally more pleasant to read than "struct{}{}".
457 var nothing = struct{}{} 457 var nothing = struct{}{}
OLDNEW
« no previous file with comments | « state/watcher.go ('k') | no next file » | no next file with comments »

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