Merge lp:~chipaca/ubuntu-push/fix-1383867 into lp:ubuntu-push/automatic

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 344
Merged at revision: 344
Proposed branch: lp:~chipaca/ubuntu-push/fix-1383867
Merge into: lp:ubuntu-push/automatic
Diff against target: 63 lines (+12/-7)
3 files modified
client/service/common.go (+6/-1)
client/service/postal.go (+5/-5)
client/service/service.go (+1/-1)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/fix-1383867
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+239369@code.launchpad.net

Commit message

make the common service Start(..) method take init, so we can listen for methods once everything is set up and not before.

Description of the change

make the common service Start(..) method take init, so we can listen for methods once everything is set up and not before.

To post a comment you must log in.
lp:~chipaca/ubuntu-push/fix-1383867 updated
344. By John Lenton

make the common service Start(..) method take init, so we can listen for methods once everything is set up and not before

Revision history for this message
John Lenton (chipaca) wrote :

Pedronis approves of this branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/service/common.go'
2--- client/service/common.go 2014-08-06 02:48:10 +0000
3+++ client/service/common.go 2014-10-23 14:15:44 +0000
4@@ -63,7 +63,7 @@
5 }
6
7 // Start() dials the bus, grab the name, and listens for method calls.
8-func (svc *DBusService) Start(dispatchMap bus.DispatchMap, busAddr bus.Address) error {
9+func (svc *DBusService) Start(dispatchMap bus.DispatchMap, busAddr bus.Address, init func() error) error {
10 svc.lock.Lock()
11 defer svc.lock.Unlock()
12 if svc.state != StateUnknown {
13@@ -89,6 +89,11 @@
14 }
15 }
16 }()
17+ if init != nil {
18+ if err = init(); err != nil {
19+ return err
20+ }
21+ }
22 svc.Bus.WatchMethod(dispatchMap, "/*", svc)
23 svc.state = StateRunning
24 return nil
25
26=== modified file 'client/service/postal.go'
27--- client/service/postal.go 2014-09-09 20:46:45 +0000
28+++ client/service/postal.go 2014-10-23 14:15:44 +0000
29@@ -141,16 +141,16 @@
30
31 // Start() dials the bus, grab the name, and listens for method calls.
32 func (svc *PostalService) Start() error {
33- err := svc.DBusService.Start(bus.DispatchMap{
34+ return svc.DBusService.Start(bus.DispatchMap{
35 "PopAll": svc.popAll,
36 "Post": svc.post,
37 "ListPersistent": svc.listPersistent,
38 "ClearPersistent": svc.clearPersistent,
39 "SetCounter": svc.setCounter,
40- }, PostalServiceBusAddress)
41- if err != nil {
42- return err
43- }
44+ }, PostalServiceBusAddress, svc.init)
45+}
46+
47+func (svc *PostalService) init() error {
48 actionsCh, err := svc.takeTheBus()
49 if err != nil {
50 return err
51
52=== modified file 'client/service/service.go'
53--- client/service/service.go 2014-07-14 19:51:43 +0000
54+++ client/service/service.go 2014-10-23 14:15:44 +0000
55@@ -89,7 +89,7 @@
56 return svc.DBusService.Start(bus.DispatchMap{
57 "Register": svc.register,
58 "Unregister": svc.unregister,
59- }, PushServiceBusAddress)
60+ }, PushServiceBusAddress, nil)
61 }
62
63 var (

Subscribers

People subscribed via source and target branches