etcd: make embedded etcd context cancelable
This commit is contained in:
parent
281c0b9d92
commit
6f3a45b75f
@ -64,8 +64,10 @@ func NewEmbeddedEtcdInstance(path string) (*BackendConfig, func(), error) {
|
|||||||
fmt.Errorf("etcd failed to start after: %v", readyTimeout)
|
fmt.Errorf("etcd failed to start after: %v", readyTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
connConfig := &BackendConfig{
|
connConfig := &BackendConfig{
|
||||||
Ctx: context.Background(),
|
Ctx: ctx,
|
||||||
Host: "http://" + peerURL,
|
Host: "http://" + peerURL,
|
||||||
User: "user",
|
User: "user",
|
||||||
Pass: "pass",
|
Pass: "pass",
|
||||||
@ -73,6 +75,7 @@ func NewEmbeddedEtcdInstance(path string) (*BackendConfig, func(), error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return connConfig, func() {
|
return connConfig, func() {
|
||||||
|
cancel()
|
||||||
etcd.Close()
|
etcd.Close()
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user