Skip to content

Commit

Permalink
Remove the closer package since it's trivial
Browse files Browse the repository at this point in the history
The only uses found were the Consul mock kv client. Even in
Cortex/Loki/Tempo the only uses were the vendored version of
the same Consul mock kv client.

Fixes #51

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
  • Loading branch information
56quarters committed Nov 2, 2021
1 parent 26c97b9 commit b2814a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
9 changes: 0 additions & 9 deletions closer/closer.go

This file was deleted.

2 changes: 1 addition & 1 deletion kv/consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions kv/consul/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion kv/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2814a7

Please sign in to comment.