etcd: Rewrite embed etcd implementation
This is a giant cleanup of the etcd code. The earlier version was written when I was less experienced with golang. This is still not perfect, and does contain some races, but at least it's a decent base to start from. The automatic elastic clustering should be considered an experimental feature. If you need a more battle-tested cluster, then you should manage etcd manually and point mgmt at your existing cluster.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package yamlgraph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
@@ -166,6 +167,10 @@ func (obj *GAPI) Next() chan gapi.Next {
|
||||
ch <- next
|
||||
return
|
||||
}
|
||||
// FIXME: add timeout to context
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
startChan := make(chan struct{}) // start signal
|
||||
close(startChan) // kick it off!
|
||||
|
||||
@@ -173,7 +178,16 @@ func (obj *GAPI) Next() chan gapi.Next {
|
||||
if obj.data.NoStreamWatch {
|
||||
watchChan = nil
|
||||
} else {
|
||||
watchChan = obj.data.World.ResWatch()
|
||||
var err error
|
||||
watchChan, err = obj.data.World.ResWatch(ctx)
|
||||
if err != nil {
|
||||
next := gapi.Next{
|
||||
Err: errwrap.Wrapf(err, "%s: could not start watch", Name),
|
||||
Exit: true, // exit, b/c programming error?
|
||||
}
|
||||
ch <- next
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user