Merge lp:~chipaca/ubuntu-push/connectivity-config-rename into lp:ubuntu-push

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 28
Merged at revision: 28
Proposed branch: lp:~chipaca/ubuntu-push/connectivity-config-rename
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/nukexample
Diff against target: 111 lines (+14/-14)
3 files modified
bus/connectivity/connectivity.go (+7/-7)
bus/connectivity/connectivity_test.go (+6/-6)
protocol/protocol.go (+1/-1)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/connectivity-config-rename
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+203638@code.launchpad.net

Commit message

Renamed bus/connectivity's Config to ConnectivityConfig.

Description of the change

Renamed bus/connectivity's Config to ConnectivityConfig.

Also added some json tags to it.

Also also, NewProtocol0 returns a Protocol, not a *protocol0.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bus/connectivity/connectivity.go'
--- bus/connectivity/connectivity.go 2014-01-23 14:33:08 +0000
+++ bus/connectivity/connectivity.go 2014-01-28 22:22:22 +0000
@@ -34,21 +34,21 @@
3434
35// the configuration for ConnectedState, with the idea that you'd populate it35// the configuration for ConnectedState, with the idea that you'd populate it
36// from a config file.36// from a config file.
37type Config struct {37type ConnectivityConfig struct {
38 // how long to wait after a state change to make sure it's "stable"38 // how long to wait after a state change to make sure it's "stable"
39 // before acting on it39 // before acting on it
40 StabilizingTimeout config.ConfigTimeDuration40 StabilizingTimeout config.ConfigTimeDuration `json:"stabilizing_timeout"`
41 // How long to wait between online connectivity checks.41 // How long to wait between online connectivity checks.
42 RecheckTimeout config.ConfigTimeDuration42 RecheckTimeout config.ConfigTimeDuration `json:"recheck_timeout"`
43 // The URL against which to do the connectivity check.43 // The URL against which to do the connectivity check.
44 ConnectivityCheckURL string44 ConnectivityCheckURL string `json:"connectivity_check_url"`
45 // The expected MD5 of the content at the ConnectivityCheckURL45 // The expected MD5 of the content at the ConnectivityCheckURL
46 ConnectivityCheckMD5 string46 ConnectivityCheckMD5 string `json:"connectivity_check_md5"`
47}47}
4848
49type connectedState struct {49type connectedState struct {
50 networkStateCh <-chan networkmanager.State50 networkStateCh <-chan networkmanager.State
51 config Config51 config ConnectivityConfig
52 log logger.Logger52 log logger.Logger
53 endp bus.Endpoint53 endp bus.Endpoint
54 connAttempts uint3254 connAttempts uint32
@@ -140,7 +140,7 @@
140//140//
141// The endpoint need not be dialed; connectivity will Dial() and Close()141// The endpoint need not be dialed; connectivity will Dial() and Close()
142// it as it sees fit.142// it as it sees fit.
143func ConnectedState(endp bus.Endpoint, config Config, log logger.Logger, out chan<- bool) {143func ConnectedState(endp bus.Endpoint, config ConnectivityConfig, log logger.Logger, out chan<- bool) {
144 wg := NewWebchecker(config.ConnectivityCheckURL, config.ConnectivityCheckMD5, log)144 wg := NewWebchecker(config.ConnectivityCheckURL, config.ConnectivityCheckMD5, log)
145 cs := &connectedState{145 cs := &connectedState{
146 config: config,146 config: config,
147147
=== modified file 'bus/connectivity/connectivity_test.go'
--- bus/connectivity/connectivity_test.go 2014-01-24 14:12:22 +0000
+++ bus/connectivity/connectivity_test.go 2014-01-28 22:22:22 +0000
@@ -58,7 +58,7 @@
58// when given a working config and bus, Start() will work58// when given a working config and bus, Start() will work
59func (s *ConnSuite) TestStartWorks(c *C) {59func (s *ConnSuite) TestStartWorks(c *C) {
60 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(networkmanager.Connecting))60 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(networkmanager.Connecting))
61 cs := connectedState{config: Config{}, log: nullog, endp: endp}61 cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
6262
63 c.Check(cs.start(), Equals, networkmanager.Connecting)63 c.Check(cs.start(), Equals, networkmanager.Connecting)
64}64}
@@ -66,7 +66,7 @@
66// if the bus fails a couple of times, we're still OK66// if the bus fails a couple of times, we're still OK
67func (s *ConnSuite) TestStartRetriesConnect(c *C) {67func (s *ConnSuite) TestStartRetriesConnect(c *C) {
68 endp := testingbus.NewTestingEndpoint(condition.Fail2Work(2), condition.Work(true), uint32(networkmanager.Connecting))68 endp := testingbus.NewTestingEndpoint(condition.Fail2Work(2), condition.Work(true), uint32(networkmanager.Connecting))
69 cs := connectedState{config: Config{}, log: nullog, endp: endp}69 cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
7070
71 c.Check(cs.start(), Equals, networkmanager.Connecting)71 c.Check(cs.start(), Equals, networkmanager.Connecting)
72 c.Check(cs.connAttempts, Equals, uint32(3)) // 1 more than the Fail2Work72 c.Check(cs.connAttempts, Equals, uint32(3)) // 1 more than the Fail2Work
@@ -75,7 +75,7 @@
75// when the calls to NetworkManager fail for a bit, we're still OK75// when the calls to NetworkManager fail for a bit, we're still OK
76func (s *ConnSuite) TestStartRetriesCall(c *C) {76func (s *ConnSuite) TestStartRetriesCall(c *C) {
77 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Fail2Work(5), uint32(networkmanager.Connecting))77 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Fail2Work(5), uint32(networkmanager.Connecting))
78 cs := connectedState{config: Config{}, log: nullog, endp: endp}78 cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
7979
80 c.Check(cs.start(), Equals, networkmanager.Connecting)80 c.Check(cs.start(), Equals, networkmanager.Connecting)
8181
@@ -93,7 +93,7 @@
93 endp := testingbus.NewTestingEndpoint(condition.Work(true), nmcond,93 endp := testingbus.NewTestingEndpoint(condition.Work(true), nmcond,
94 uint32(networkmanager.Connecting),94 uint32(networkmanager.Connecting),
95 uint32(networkmanager.ConnectedGlobal))95 uint32(networkmanager.ConnectedGlobal))
96 cs := connectedState{config: Config{}, log: nullog, endp: endp}96 cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
9797
98 c.Check(cs.start(), Equals, networkmanager.Connecting)98 c.Check(cs.start(), Equals, networkmanager.Connecting)
99 c.Check(cs.connAttempts, Equals, uint32(2))99 c.Check(cs.connAttempts, Equals, uint32(2))
@@ -109,7 +109,7 @@
109 var webget_p condition.Interface = condition.Work(true)109 var webget_p condition.Interface = condition.Work(true)
110 recheck_timeout := 50 * time.Millisecond110 recheck_timeout := 50 * time.Millisecond
111111
112 cfg := Config{112 cfg := ConnectivityConfig{
113 RecheckTimeout: config.ConfigTimeDuration{recheck_timeout},113 RecheckTimeout: config.ConfigTimeDuration{recheck_timeout},
114 }114 }
115 ch := make(chan networkmanager.State, 10)115 ch := make(chan networkmanager.State, 10)
@@ -184,7 +184,7 @@
184 ts := httptest.NewServer(mkHandler(staticText))184 ts := httptest.NewServer(mkHandler(staticText))
185 defer ts.Close()185 defer ts.Close()
186186
187 cfg := Config{187 cfg := ConnectivityConfig{
188 ConnectivityCheckURL: ts.URL,188 ConnectivityCheckURL: ts.URL,
189 ConnectivityCheckMD5: staticHash,189 ConnectivityCheckMD5: staticHash,
190 RecheckTimeout: config.ConfigTimeDuration{time.Second},190 RecheckTimeout: config.ConfigTimeDuration{time.Second},
191191
=== modified file 'protocol/protocol.go'
--- protocol/protocol.go 2014-01-14 15:35:20 +0000
+++ protocol/protocol.go 2014-01-28 22:22:22 +0000
@@ -55,7 +55,7 @@
55}55}
5656
57// NewProtocol0 creates and initialises a protocol with wire format version 0.57// NewProtocol0 creates and initialises a protocol with wire format version 0.
58func NewProtocol0(conn net.Conn) *protocol0 {58func NewProtocol0(conn net.Conn) Protocol {
59 buf := bytes.NewBuffer(make([]byte, 5000))59 buf := bytes.NewBuffer(make([]byte, 5000))
60 return &protocol0{60 return &protocol0{
61 buffer: buf,61 buffer: buf,

Subscribers

People subscribed via source and target branches