Skip to content

Commit

Permalink
Doc: Add godoc to gossip package.
Browse files Browse the repository at this point in the history
Refers to #40
  • Loading branch information
Jose Luis Lucas committed Jun 14, 2019
1 parent 5997ba3 commit 12fb68b
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 24 deletions.
6 changes: 5 additions & 1 deletion gossip/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package gossip implements functionality to build gossip agents
// and control their life cycle: start/stop, join/leave the gossip network,
// send messages, ...
package gossip

import (
Expand Down Expand Up @@ -307,7 +311,7 @@ func (a *Agent) Send(msg *Message) {
msg.From = a.Self
for _, dst := range a.route(msg.From) {
log.Debugf("Sending batch to %+v\n", dst.Name)
a.gossip.SendReliable(dst, wire)
_ = a.gossip.SendReliable(dst, wire)
}
}

Expand Down
4 changes: 2 additions & 2 deletions gossip/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestJoin(t *testing.T) {
require.Equal(t, c.expectedContactedHosts, result, "Wrong expected contacted hosts in test %d.", i)
require.Equal(t, c.expectedErr, err, "Wrong expected error in test %d.", i)
}
a.Shutdown()
_ = a.Shutdown()
}

func TestLeave(t *testing.T) {
Expand Down Expand Up @@ -113,5 +113,5 @@ func TestLeave(t *testing.T) {
require.Equal(t, c.expectedErr, err, "Wrong expected error in test %d.", i)
require.Equal(t, c.finalStatus, a.Self.Status, "Wrong expected status in test %d.", i)
}
a.Shutdown()
_ = a.Shutdown()
}
2 changes: 1 addition & 1 deletion gossip/bus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestMessageBus(t *testing.T) {
Payload: nil,
}
mb.Subscribe(BatchMessageType, &ts, 1)
mb.Publish(m1)
_ = mb.Publish(m1)
m2 := <-ts.ch
require.Equal(t, m2, m1, "Messages should match")
}
Expand Down
8 changes: 4 additions & 4 deletions gossip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ type eventDelegate struct {
func (e *eventDelegate) NotifyJoin(n *memberlist.Node) {
peer := ParsePeer(n)
peer.Status = AgentStatusAlive
e.agent.topology.Update(peer)
_ = e.agent.topology.Update(peer)
log.Debugf("member joined: %+v ", peer)
}

// NotifyLeave is invoked when a node is detected to have left.
func (e *eventDelegate) NotifyLeave(n *memberlist.Node) {
peer := ParsePeer(n)
e.agent.topology.Delete(peer)
_ = e.agent.topology.Delete(peer)
log.Debugf("member left: %+v", peer)
}

Expand All @@ -48,7 +48,7 @@ func (e *eventDelegate) NotifyLeave(n *memberlist.Node) {
func (e *eventDelegate) NotifyUpdate(n *memberlist.Node) {
// ignore
peer := ParsePeer(n)
e.agent.topology.Update(peer)
_ = e.agent.topology.Update(peer)
log.Debugf("member updated: %+v ", peer)
}

Expand Down Expand Up @@ -83,7 +83,7 @@ func (d *agentDelegate) NotifyMsg(msg []byte) {
if err != nil {
log.Infof("Agent Deletage unable to decode gossip message!: %v", err)
}
d.agent.In.Publish(m)
_ = d.agent.In.Publish(m)
}

// GetBroadcasts is called when user data messages can be broadcast.
Expand Down
2 changes: 1 addition & 1 deletion gossip/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestMessageEncodeDecode(t *testing.T) {

buff, err := m1.Encode()
require.NoError(t, err, "Encoding must end succesfully")
m2.Decode(buff)
_ = m2.Decode(buff)
require.Equal(t, &m2, m1, "Messages must be equal")

}
2 changes: 1 addition & 1 deletion gossip/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewSimpleNotifier(endpoint []string, size int, dialTimeout, readTimeout tim
return nil, err
}
// timeout reading from the connection
conn.SetDeadline(time.Now().Add(readTimeout))
_ = conn.SetDeadline(time.Now().Add(readTimeout))
return conn, nil
},
}}
Expand Down
2 changes: 1 addition & 1 deletion gossip/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestDefaultAlert(t *testing.T) {
notificator.Start()
defer notificator.Stop()

notificator.Alert("test alert")
_ = notificator.Alert("test alert")
time.Sleep(1 * time.Second)

require.True(t, called, "Server must be called from alerter")
Expand Down
4 changes: 2 additions & 2 deletions gossip/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (d *BatchProcessor) wasProcessed(b *protocol.BatchSnapshots) bool {
if err == nil {
return true
}
d.a.Cache.Set(digest, []byte{0x1}, 0)
_ = d.a.Cache.Set(digest, []byte{0x1}, 0)
return false
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func (d *BatchProcessor) Subscribe(id int, ch <-chan *Message) {
}
}

d.a.Out.Publish(msg)
_ = d.a.Out.Publish(msg)
case <-d.quitCh:
return
}
Expand Down
8 changes: 4 additions & 4 deletions gossip/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestBatchProcessorLoop(t *testing.T) {
}
}()

a.In.Publish(m1)
_ = a.In.Publish(m1)

wg.Wait()
}
Expand Down Expand Up @@ -99,8 +99,8 @@ func TestBatchProcessorWasProcessed(t *testing.T) {
Payload: buf,
}

a.In.Publish(m1)
a.In.Publish(m1)
_ = a.In.Publish(m1)
_ = a.In.Publish(m1)
// give time for the scheduler to route all the messages
time.Sleep(1 * time.Second)

Expand Down Expand Up @@ -148,7 +148,7 @@ func TestBatchProcessorRegisterMetrics(t *testing.T) {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, _ := ioutil.ReadAll(resp.Body)
found := strings.Index(string(body), "fakeCounterMetric")

require.True(t, found > 0, "Metric not found!")
Expand Down
2 changes: 1 addition & 1 deletion gossip/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewRestSnapshotStore(endpoint []string, dialTimeout, readTimeout time.Durat
return nil, err
}
// timeout reading from the connection
conn.SetDeadline(time.Now().Add(readTimeout))
_ = conn.SetDeadline(time.Now().Add(readTimeout))
return conn, nil
},
}}
Expand Down
2 changes: 1 addition & 1 deletion gossip/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestDefaultStore(t *testing.T) {
conf.Endpoint = append(conf.Endpoint, server.URL)
store := NewRestSnapshotStoreFromConfig(conf)

store.PutBatch(&protocol.BatchSnapshots{})
_ = store.PutBatch(&protocol.BatchSnapshots{})

time.Sleep(1 * time.Second)

Expand Down
1 change: 0 additions & 1 deletion gossip/taskmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ type SimpleTasksManager struct {
taskCh chan Task
quitCh chan bool
ticker *time.Ticker
timeout time.Duration
maxTasks int
}

Expand Down
2 changes: 1 addition & 1 deletion gossip/taskmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestRunLen(t *testing.T) {
tm := NewSimpleTasksManager(100*time.Millisecond, 1)
tm.Start()
executions := 0
tm.Add(func() error {
_ = tm.Add(func() error {
executions++
return nil
})
Expand Down
6 changes: 3 additions & 3 deletions gossip/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func setupTopology(size int) *Topology {
port := uint16(9000 + i)
role := roles[i%len(roles)]
peer := NewPeer(name, "127.0.0.1", port, role)
topology.Update(peer)
_ = topology.Update(peer)
}
return topology
}
Expand All @@ -39,12 +39,12 @@ func TestUpdateAndDeleteTopology(t *testing.T) {
topology := NewTopology()

peer := NewPeer("auditor", "127.0.0.1", 9000, "auditor")
topology.Update(peer)
_ = topology.Update(peer)

auditors := topology.Get("auditor")
require.Truef(t, 1 == auditors.Size(), "The topology must include one auditor")

topology.Delete(peer)
_ = topology.Delete(peer)

auditors = topology.Get("auditor")
require.Truef(t, 0 == auditors.Size(), "The topology must include zero auditor")
Expand Down

0 comments on commit 12fb68b

Please sign in to comment.