Skip to content
Snippets Groups Projects
Commit d9e1bf1f authored by ale's avatar ale
Browse files

reduce stutter with NewMasterElection

parent db380a83
Branches
No related tags found
No related merge requests found
...@@ -51,11 +51,10 @@ type MasterElection struct { ...@@ -51,11 +51,10 @@ type MasterElection struct {
state State state State
} }
// NewMasterElection creates a new MasterElection object that will // New creates a new MasterElection object that will establish a lock
// establish a lock on 'path'. It will send state transitions to // on 'path'. It will send state transitions to 'sch', if provided. If
// 'sch', if provided. If 'sch' is not nil, it will be closed when // 'sch' is not nil, it will be closed when Run() terminates.
// Run() terminates. func New(client autoradio.EtcdClient, path, data string, ttl uint64, sch chan State) *MasterElection {
func NewMasterElection(client autoradio.EtcdClient, path, data string, ttl uint64, sch chan State) *MasterElection {
if ttl < 1 { if ttl < 1 {
ttl = 1 ttl = 1
} }
......
...@@ -47,7 +47,7 @@ func TestMasterElection(t *testing.T) { ...@@ -47,7 +47,7 @@ func TestMasterElection(t *testing.T) {
var stop []chan bool var stop []chan bool
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
stopCh := make(chan bool) stopCh := make(chan bool)
m := NewMasterElection( m := New(
etcd, etcd,
lockPath, lockPath,
fmt.Sprintf("%d", i), fmt.Sprintf("%d", i),
......
...@@ -313,7 +313,7 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, max ...@@ -313,7 +313,7 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, max
name: name, name: name,
ips: ips, ips: ips,
client: client, client: client,
me: masterelection.NewMasterElection( me: masterelection.New(
client, client,
autoradio.MasterElectionPath, autoradio.MasterElectionPath,
string(minfodata), string(minfodata),
...@@ -565,7 +565,7 @@ func (t *transcoder) run() { ...@@ -565,7 +565,7 @@ func (t *transcoder) run() {
// within the scope of this function. // within the scope of this function.
update := make(chan masterelection.State) update := make(chan masterelection.State)
mestop := make(chan bool) mestop := make(chan bool)
me := masterelection.NewMasterElection( me := masterelection.New(
t.client, t.client,
autoradio.TranscoderMasterElectionBase+t.params.TargetMount, autoradio.TranscoderMasterElectionBase+t.params.TargetMount,
t.nodeName, t.nodeName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment