From 6f302d01f62fa4857a19686ae428c8d9c4381bf1 Mon Sep 17 00:00:00 2001 From: Vytenis Darulis Date: Wed, 2 Dec 2020 23:19:25 -0500 Subject: [PATCH] lint --- src/cluster/client/etcd/client.go | 22 +++++++++++----------- src/cluster/client/etcd/client_test.go | 2 +- src/cluster/client/etcd/types.go | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cluster/client/etcd/client.go b/src/cluster/client/etcd/client.go index 8601dbf507..927e384b9f 100644 --- a/src/cluster/client/etcd/client.go +++ b/src/cluster/client/etcd/client.go @@ -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 @@ -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 { @@ -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 diff --git a/src/cluster/client/etcd/client_test.go b/src/cluster/client/etcd/client_test.go index b22560943f..6d184412b6 100644 --- a/src/cluster/client/etcd/client_test.go +++ b/src/cluster/client/etcd/client_test.go @@ -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") diff --git a/src/cluster/client/etcd/types.go b/src/cluster/client/etcd/types.go index ca14902216..a387357890 100644 --- a/src/cluster/client/etcd/types.go +++ b/src/cluster/client/etcd/types.go @@ -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 }