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
1=== modified file 'bus/connectivity/connectivity.go'
2--- bus/connectivity/connectivity.go 2014-01-23 14:33:08 +0000
3+++ bus/connectivity/connectivity.go 2014-01-28 22:22:22 +0000
4@@ -34,21 +34,21 @@
5
6 // the configuration for ConnectedState, with the idea that you'd populate it
7 // from a config file.
8-type Config struct {
9+type ConnectivityConfig struct {
10 // how long to wait after a state change to make sure it's "stable"
11 // before acting on it
12- StabilizingTimeout config.ConfigTimeDuration
13+ StabilizingTimeout config.ConfigTimeDuration `json:"stabilizing_timeout"`
14 // How long to wait between online connectivity checks.
15- RecheckTimeout config.ConfigTimeDuration
16+ RecheckTimeout config.ConfigTimeDuration `json:"recheck_timeout"`
17 // The URL against which to do the connectivity check.
18- ConnectivityCheckURL string
19+ ConnectivityCheckURL string `json:"connectivity_check_url"`
20 // The expected MD5 of the content at the ConnectivityCheckURL
21- ConnectivityCheckMD5 string
22+ ConnectivityCheckMD5 string `json:"connectivity_check_md5"`
23 }
24
25 type connectedState struct {
26 networkStateCh <-chan networkmanager.State
27- config Config
28+ config ConnectivityConfig
29 log logger.Logger
30 endp bus.Endpoint
31 connAttempts uint32
32@@ -140,7 +140,7 @@
33 //
34 // The endpoint need not be dialed; connectivity will Dial() and Close()
35 // it as it sees fit.
36-func ConnectedState(endp bus.Endpoint, config Config, log logger.Logger, out chan<- bool) {
37+func ConnectedState(endp bus.Endpoint, config ConnectivityConfig, log logger.Logger, out chan<- bool) {
38 wg := NewWebchecker(config.ConnectivityCheckURL, config.ConnectivityCheckMD5, log)
39 cs := &connectedState{
40 config: config,
41
42=== modified file 'bus/connectivity/connectivity_test.go'
43--- bus/connectivity/connectivity_test.go 2014-01-24 14:12:22 +0000
44+++ bus/connectivity/connectivity_test.go 2014-01-28 22:22:22 +0000
45@@ -58,7 +58,7 @@
46 // when given a working config and bus, Start() will work
47 func (s *ConnSuite) TestStartWorks(c *C) {
48 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(networkmanager.Connecting))
49- cs := connectedState{config: Config{}, log: nullog, endp: endp}
50+ cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
51
52 c.Check(cs.start(), Equals, networkmanager.Connecting)
53 }
54@@ -66,7 +66,7 @@
55 // if the bus fails a couple of times, we're still OK
56 func (s *ConnSuite) TestStartRetriesConnect(c *C) {
57 endp := testingbus.NewTestingEndpoint(condition.Fail2Work(2), condition.Work(true), uint32(networkmanager.Connecting))
58- cs := connectedState{config: Config{}, log: nullog, endp: endp}
59+ cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
60
61 c.Check(cs.start(), Equals, networkmanager.Connecting)
62 c.Check(cs.connAttempts, Equals, uint32(3)) // 1 more than the Fail2Work
63@@ -75,7 +75,7 @@
64 // when the calls to NetworkManager fail for a bit, we're still OK
65 func (s *ConnSuite) TestStartRetriesCall(c *C) {
66 endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Fail2Work(5), uint32(networkmanager.Connecting))
67- cs := connectedState{config: Config{}, log: nullog, endp: endp}
68+ cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
69
70 c.Check(cs.start(), Equals, networkmanager.Connecting)
71
72@@ -93,7 +93,7 @@
73 endp := testingbus.NewTestingEndpoint(condition.Work(true), nmcond,
74 uint32(networkmanager.Connecting),
75 uint32(networkmanager.ConnectedGlobal))
76- cs := connectedState{config: Config{}, log: nullog, endp: endp}
77+ cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
78
79 c.Check(cs.start(), Equals, networkmanager.Connecting)
80 c.Check(cs.connAttempts, Equals, uint32(2))
81@@ -109,7 +109,7 @@
82 var webget_p condition.Interface = condition.Work(true)
83 recheck_timeout := 50 * time.Millisecond
84
85- cfg := Config{
86+ cfg := ConnectivityConfig{
87 RecheckTimeout: config.ConfigTimeDuration{recheck_timeout},
88 }
89 ch := make(chan networkmanager.State, 10)
90@@ -184,7 +184,7 @@
91 ts := httptest.NewServer(mkHandler(staticText))
92 defer ts.Close()
93
94- cfg := Config{
95+ cfg := ConnectivityConfig{
96 ConnectivityCheckURL: ts.URL,
97 ConnectivityCheckMD5: staticHash,
98 RecheckTimeout: config.ConfigTimeDuration{time.Second},
99
100=== modified file 'protocol/protocol.go'
101--- protocol/protocol.go 2014-01-14 15:35:20 +0000
102+++ protocol/protocol.go 2014-01-28 22:22:22 +0000
103@@ -55,7 +55,7 @@
104 }
105
106 // NewProtocol0 creates and initialises a protocol with wire format version 0.
107-func NewProtocol0(conn net.Conn) *protocol0 {
108+func NewProtocol0(conn net.Conn) Protocol {
109 buf := bytes.NewBuffer(make([]byte, 5000))
110 return &protocol0{
111 buffer: buf,

Subscribers

People subscribed via source and target branches