Refactor etcd into object and add exit timers

This refactors my etcd use into a struct (object) wrapper, which makes
it easier to add an exit on converged timer.
This commit is contained in:
James Shubin
2016-01-06 19:35:29 -05:00
parent 95489b9c07
commit 72525d30b1
9 changed files with 205 additions and 30 deletions

View File

@@ -95,7 +95,7 @@ func (g *Graph) SetName(name string) {
g.Name = name
}
func (g *Graph) State() graphState {
func (g *Graph) GetState() graphState {
g.mutex.Lock()
defer g.mutex.Unlock()
return g.state
@@ -577,6 +577,12 @@ func (g *Graph) Exit() {
}
}
func (g *Graph) SetConvergedCallback(ctimeout int, converged chan bool) {
for v := range g.GetVerticesChan() {
v.Type.SetConvegedCallback(ctimeout, converged)
}
}
// in array function to test *vertices in a slice of *vertices
func HasVertex(v *Vertex, haystack []*Vertex) bool {
for _, r := range haystack {