Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis committed Dec 3, 2020
1 parent ddb90f0 commit 6f302d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions src/cluster/client/etcd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ const (

var errInvalidNamespace = errors.New("invalid namespace")

var (
// make sure m3cluster and etcd client interfaces are implemented, and
// EtcdConfigService is a superset of cluster client.
_ client.Client = EtcdConfigService((*csclient)(nil))
)
// make sure m3cluster and etcd client interfaces are implemented, and that
// Client is a superset of cluster.Client.
var _ client.Client = Client((*csclient)(nil))

type newClientFn func(cluster Cluster) (*clientv3.Client, error)

type cacheFileForZoneFn func(zone string) etcdkv.CacheFileFn

// EtcdClient is a cached etcd client for a zone.
type EtcdClient struct {
// ZoneClient is a cached etcd client for a zone.
type ZoneClient struct {
Client *clientv3.Client
Zone string
}

// NewEtcdConfigServiceClient returns a new etcd-backed cluster client.
//nolint:golint
func NewEtcdConfigServiceClient(opts Options) (*csclient, error) {
if err := opts.Validate(); err != nil {
return nil, err
Expand Down Expand Up @@ -293,14 +293,14 @@ func (c *csclient) etcdClientGen(zone string) (*clientv3.Client, error) {
return cli, nil
}

// EtcdClients returns all currently cached etcd clients.
func (c *csclient) EtcdClients() []EtcdClient {
// Clients returns all currently cached etcd clients.
func (c *csclient) Clients() []ZoneClient {
c.Lock()
defer c.Unlock()

var (
zones = make([]string, 0, len(c.clis))
clients = make([]EtcdClient, 0, len(c.clis))
clients = make([]ZoneClient, 0, len(c.clis))
)

for k := range c.clis {
Expand All @@ -310,7 +310,7 @@ func (c *csclient) EtcdClients() []EtcdClient {
sort.Strings(zones)

for _, zone := range zones {
clients = append(clients, EtcdClient{Zone: zone, Client: c.clis[zone]})
clients = append(clients, ZoneClient{Zone: zone, Client: c.clis[zone]})
}

return clients
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/client/etcd/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestGetEtcdClients(t *testing.T) {
require.Equal(t, 2, len(c.clis))
require.False(t, c1 == c2)

clients := c.EtcdClients()
clients := c.Clients()
require.Len(t, clients, 2)

assert.Equal(t, clients[0].Zone, "zone1")
Expand Down
6 changes: 3 additions & 3 deletions src/cluster/client/etcd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ type Cluster interface {
SetDialTimeout(value time.Duration) Cluster
}

// EtcdConfigService is an etcd-backed m3cluster client.
type EtcdConfigService interface {
// Client is an etcd-backed m3cluster client.
type Client interface {
client.Client

EtcdClients() []EtcdClient
Clients() []ZoneClient
}

0 comments on commit 6f302d0

Please sign in to comment.