diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb6790f7..9492eed38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog +* [CHANGE] Closer: remove the closer package since it's trivial to just copy/paste. #70 * [CHANGE] Memberlist: allow specifying address and port advertised to the memberlist cluster members by setting the following configuration: #37 * `-memberlist.advertise_addr` * `-memberlist.advertise_port` diff --git a/closer/closer.go b/closer/closer.go deleted file mode 100644 index 3402f5d57..000000000 --- a/closer/closer.go +++ /dev/null @@ -1,9 +0,0 @@ -package closer - -// Func is like http.HandlerFunc but for io.Closers. -type Func func() error - -// Close implements io.Closer. -func (f Func) Close() error { - return f() -} diff --git a/kv/consul/client.go b/kv/consul/client.go index b3391c9cd..69219cf74 100644 --- a/kv/consul/client.go +++ b/kv/consul/client.go @@ -59,7 +59,7 @@ type kv interface { Put(p *consul.KVPair, q *consul.WriteOptions) (*consul.WriteMeta, error) } -// Client is a KV.Client for Consul. +// Client is a kv.Client for Consul. type Client struct { kv codec codec.Codec diff --git a/kv/consul/mock.go b/kv/consul/mock.go index ae9c768f9..f1f6937f0 100644 --- a/kv/consul/mock.go +++ b/kv/consul/mock.go @@ -12,7 +12,6 @@ import ( consul "github.com/hashicorp/consul/api" "github.com/prometheus/client_golang/prometheus" - "github.com/grafana/dskit/closer" "github.com/grafana/dskit/kv/codec" ) @@ -48,7 +47,7 @@ func NewInMemoryClientWithConfig(codec codec.Codec, cfg Config, logger log.Logge // Create a closer function used to close the main loop and wait until it's done. // We need to wait until done, otherwise the goroutine leak finder used in tests // may still report it as leaked. - closer := closer.Func(func() error { + closer := closerFunc(func() error { close(m.close) m.closeWG.Wait() return nil @@ -67,6 +66,12 @@ func NewInMemoryClientWithConfig(codec codec.Codec, cfg Config, logger log.Logge }, closer } +type closerFunc func() error + +func (c closerFunc) Close() error { + return c() +} + func copyKVPair(in *consul.KVPair) *consul.KVPair { out := *in out.Value = make([]byte, len(in.Value)) diff --git a/kv/etcd/etcd.go b/kv/etcd/etcd.go index b08fb6a9d..fa6944d4f 100644 --- a/kv/etcd/etcd.go +++ b/kv/etcd/etcd.go @@ -38,7 +38,7 @@ type Clientv3Facade interface { clientv3.Watcher } -// Client implements ring.KVClient for etcd. +// Client implements kv.Client for etcd. type Client struct { cfg Config codec codec.Codec