From f3a4f77021337aaadb05b95450806fe41340f7b6 Mon Sep 17 00:00:00 2001 From: gotjosh Date: Thu, 25 Feb 2021 16:00:49 +0000 Subject: [PATCH] Use an interface for the Channel too Signed-off-by: gotjosh --- cluster/cluster.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cluster/cluster.go b/cluster/cluster.go index d426b633..bcbe0cf8 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -51,6 +51,11 @@ type ClusterMember interface { Address() string } +// ClusterChannel supports state broadcasting across peers. +type ClusterChannel interface { + Broadcast([]byte) +} + // Peer is a single peer in a gossip cluster. type Peer struct { mlist *memberlist.Memberlist @@ -530,7 +535,7 @@ func (p *Peer) peerUpdate(n *memberlist.Node) { // AddState adds a new state that will be gossiped. It returns a channel to which // broadcast messages for the state can be sent. -func (p *Peer) AddState(key string, s State, reg prometheus.Registerer) *Channel { +func (p *Peer) AddState(key string, s State, reg prometheus.Registerer) ClusterChannel { p.states[key] = s send := func(b []byte) { p.delegate.bcast.QueueBroadcast(simpleBroadcast(b))