Merge lp:~chipaca/ubuntu-push/endpoint-not-bus into lp:ubuntu-push

Proposed by John Lenton
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 22
Merged at revision: 25
Proposed branch: lp:~chipaca/ubuntu-push/endpoint-not-bus
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/bus-reorg
Diff against target: 151 lines (+25/-58)
4 files modified
bus/notifications/raw.go (+3/-8)
bus/notifications/raw_test.go (+13/-29)
bus/urldispatcher/urldispatcher.go (+3/-7)
bus/urldispatcher/urldispatcher_test.go (+6/-14)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/endpoint-not-bus
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+203060@code.launchpad.net

This proposal supersedes a proposal from 2014-01-23.

Commit message

change a few of the bus/* services to take a bus.Endpoint instead of a bus.Bus

Description of the change

change a few of the bus/* services to take a bus.Endpoint instead of a bus.Bus

To post a comment you must log in.
Revision history for this message
Samuele Pedroni (pedronis) wrote :

I see where this is going from the other branches,

the interfaces where you have to hand over a nm endpoint to connectivity is a bit strange though

Revision history for this message
Samuele Pedroni (pedronis) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bus/notifications/raw.go'
--- bus/notifications/raw.go 2014-01-24 13:21:18 +0000
+++ bus/notifications/raw.go 2014-01-24 13:21:18 +0000
@@ -52,14 +52,9 @@
52 log logger.Logger52 log logger.Logger
53}53}
5454
55// Raw returns a new RawNotifications connected to the provided bus.Bus55// Raw returns a new RawNotifications that'll use the provided bus.Endpoint
56func Raw(bt bus.Bus, log logger.Logger) (*RawNotifications, error) {56func Raw(endp bus.Endpoint, log logger.Logger) *RawNotifications {
57 endp, err := bt.Connect(BusAddress, log)57 return &RawNotifications{endp, log}
58 if err != nil {
59 return nil, err
60 }
61
62 return &RawNotifications{endp, log}, nil
63}58}
6459
65/*60/*
6661
=== modified file 'bus/notifications/raw_test.go'
--- bus/notifications/raw_test.go 2014-01-24 13:21:18 +0000
+++ bus/notifications/raw_test.go 2014-01-24 13:21:18 +0000
@@ -38,47 +38,32 @@
3838
39var nullog = logger.NewSimpleLogger(ioutil.Discard, "error")39var nullog = logger.NewSimpleLogger(ioutil.Discard, "error")
4040
41func (s *RawSuite) TestConnects(c *C) {
42 bus := testibus.NewTestingBus(condition.Work(false), condition.Work(false))
43 _, err := Raw(bus, nullog)
44 c.Check(err, NotNil)
45 bus = testibus.NewTestingBus(condition.Work(true), condition.Work(false))
46 _, err = Raw(bus, nullog)
47 c.Check(err, IsNil)
48}
49
50func (s *RawSuite) TestNotifies(c *C) {41func (s *RawSuite) TestNotifies(c *C) {
51 bus := testibus.NewTestingBus(condition.Work(true), condition.Work(true),42 endp := testibus.NewTestingEndpoint(condition.Work(true), uint32(1))
52 uint32(1))43 raw := Raw(endp, nullog)
53 raw, err := Raw(bus, nullog)
54 c.Assert(err, IsNil)
55 nid, err := raw.Notify("", 0, "", "", "", nil, nil, 0)44 nid, err := raw.Notify("", 0, "", "", "", nil, nil, 0)
56 c.Check(err, IsNil)45 c.Check(err, IsNil)
57 c.Check(nid, Equals, uint32(1))46 c.Check(nid, Equals, uint32(1))
58}47}
5948
60func (s *RawSuite) TestNotifiesFails(c *C) {49func (s *RawSuite) TestNotifiesFails(c *C) {
61 bus := testibus.NewTestingBus(condition.Work(true), condition.Work(false))50 endp := testibus.NewTestingEndpoint(condition.Work(false))
62 raw, err := Raw(bus, nullog)51 raw := Raw(endp, nullog)
63 c.Assert(err, IsNil)52 _, err := raw.Notify("", 0, "", "", "", nil, nil, 0)
64 _, err = raw.Notify("", 0, "", "", "", nil, nil, 0)
65 c.Check(err, NotNil)53 c.Check(err, NotNil)
66}54}
6755
68func (s *RawSuite) TestNotifiesFailsWeirdly(c *C) {56func (s *RawSuite) TestNotifiesFailsWeirdly(c *C) {
69 bus := testibus.NewMultiValuedTestingBus(condition.Work(true), condition.Work(true),57 endp := testibus.NewMultiValuedTestingEndpoint(condition.Work(true), []interface{}{1, 2})
70 []interface{}{1, 2})58 raw := Raw(endp, nullog)
71 raw, err := Raw(bus, nullog)59 _, err := raw.Notify("", 0, "", "", "", nil, nil, 0)
72 c.Assert(err, IsNil)
73 _, err = raw.Notify("", 0, "", "", "", nil, nil, 0)
74 c.Check(err, NotNil)60 c.Check(err, NotNil)
75}61}
7662
77func (s *RawSuite) TestWatchActions(c *C) {63func (s *RawSuite) TestWatchActions(c *C) {
78 bus := testibus.NewMultiValuedTestingBus(condition.Work(true), condition.Work(true),64 endp := testibus.NewMultiValuedTestingEndpoint(condition.Work(true),
79 []interface{}{uint32(1), "hello"})65 []interface{}{uint32(1), "hello"})
80 raw, err := Raw(bus, nullog)66 raw := Raw(endp, nullog)
81 c.Assert(err, IsNil)
82 ch, err := raw.WatchActions()67 ch, err := raw.WatchActions()
83 c.Assert(err, IsNil)68 c.Assert(err, IsNil)
84 // check we get the right action reply69 // check we get the right action reply
@@ -95,9 +80,8 @@
95}80}
9681
97func (s *RawSuite) TestWatchActionsFails(c *C) {82func (s *RawSuite) TestWatchActionsFails(c *C) {
98 bus := testibus.NewTestingBus(condition.Work(true), condition.Work(false))83 endp := testibus.NewTestingEndpoint(condition.Work(false))
99 raw, err := Raw(bus, nullog)84 raw := Raw(endp, nullog)
100 c.Assert(err, IsNil)85 _, err := raw.WatchActions()
101 _, err = raw.WatchActions()
102 c.Check(err, NotNil)86 c.Check(err, NotNil)
103}87}
10488
=== modified file 'bus/urldispatcher/urldispatcher.go'
--- bus/urldispatcher/urldispatcher.go 2014-01-24 13:21:18 +0000
+++ bus/urldispatcher/urldispatcher.go 2014-01-24 13:21:18 +0000
@@ -40,13 +40,9 @@
40 log logger.Logger40 log logger.Logger
41}41}
4242
43// New builds a new URL dispatcher by connecting to the provided bus.43// New builds a new URL dispatcher that uses the provided bus.Endpoint
44func New(bus bus.Bus, log logger.Logger) (URLDispatcher, error) {44func New(endp bus.Endpoint, log logger.Logger) URLDispatcher {
45 endp, err := bus.Connect(BusAddress, log)45 return &urlDispatcher{endp, log}
46 if err != nil {
47 return nil, err
48 }
49 return &urlDispatcher{endp, log}, nil
50}46}
5147
52var _ URLDispatcher = &urlDispatcher{} // ensures it conforms48var _ URLDispatcher = &urlDispatcher{} // ensures it conforms
5349
=== modified file 'bus/urldispatcher/urldispatcher_test.go'
--- bus/urldispatcher/urldispatcher_test.go 2014-01-24 13:21:18 +0000
+++ bus/urldispatcher/urldispatcher_test.go 2014-01-24 13:21:18 +0000
@@ -35,23 +35,15 @@
35var nullog = logger.NewSimpleLogger(ioutil.Discard, "error")35var nullog = logger.NewSimpleLogger(ioutil.Discard, "error")
3636
37func (s *UDSuite) TestWorks(c *C) {37func (s *UDSuite) TestWorks(c *C) {
38 tb := testibus.NewMultiValuedTestingBus(condition.Work(true), condition.Work(true), []interface{}{})38 endp := testibus.NewMultiValuedTestingEndpoint(condition.Work(true), []interface{}{})
39 ud, err := New(tb, nullog)39 ud := New(endp, nullog)
40 c.Assert(err, IsNil)40 err := ud.DispatchURL("this")
41 err = ud.DispatchURL("this")
42 c.Check(err, IsNil)41 c.Check(err, IsNil)
43}42}
4443
45func (s *UDSuite) TestFailsIfConnectFails(c *C) {
46 tb := testibus.NewTestingBus(condition.Work(false), condition.Work(true))
47 _, err := New(tb, nullog)
48 c.Check(err, NotNil)
49}
50
51func (s *UDSuite) TestFailsIfCallFails(c *C) {44func (s *UDSuite) TestFailsIfCallFails(c *C) {
52 tb := testibus.NewTestingBus(condition.Work(true), condition.Work(false))45 endp := testibus.NewTestingEndpoint(condition.Work(false))
53 ud, err := New(tb, nullog)46 ud := New(endp, nullog)
54 c.Assert(err, IsNil)47 err := ud.DispatchURL("this")
55 err = ud.DispatchURL("this")
56 c.Check(err, NotNil)48 c.Check(err, NotNil)
57}49}

Subscribers

People subscribed via source and target branches