Skip to content

Commit

Permalink
Renamed memcached config option addrs to addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
pracucci committed Jan 3, 2020
1 parent da13b4b commit f1482f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/components/store.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ The `memcached` index cache allows to use [Memcached](https://memcached.org) as
```yaml
type: MEMCACHED
config:
addrs: []
addresses: []
timeout: 0s
max_idle_connections: 0
max_async_concurrency: 0
Expand All @@ -210,7 +210,7 @@ config:

The **required** settings are:

- `addrs`: list of memcached addresses, that will get resolved with the [DNS service discovery](../service-discovery.md/#dns-service-discovery) provider.
- `addresses`: list of memcached addresses, that will get resolved with the [DNS service discovery](../service-discovery.md/#dns-service-discovery) provider.

While the remaining settings are **optional**:

Expand Down
10 changes: 5 additions & 5 deletions pkg/cacheutil/memcached_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

var (
errMemcachedAsyncBufferFull = errors.New("the async buffer is full")
errMemcachedConfigNoAddrs = errors.New("no memcached addrs provided")
errMemcachedConfigNoAddrs = errors.New("no memcached addresses provided")

defaultMemcachedClientConfig = MemcachedClientConfig{
Timeout: 500 * time.Millisecond,
Expand Down Expand Up @@ -60,9 +60,9 @@ type memcachedClientBackend interface {

// MemcachedClientConfig is the config accepted by MemcachedClient.
type MemcachedClientConfig struct {
// Addrs specifies the list of memcached addresses. The addresses get
// Addresses specifies the list of memcached addresses. The addresses get
// resolved with the DNS provider.
Addrs []string `yaml:"addrs"`
Addresses []string `yaml:"addresses"`

// Timeout specifies the socket read/write timeout.
Timeout time.Duration `yaml:"timeout"`
Expand Down Expand Up @@ -95,7 +95,7 @@ type MemcachedClientConfig struct {
}

func (c *MemcachedClientConfig) validate() error {
if len(c.Addrs) == 0 {
if len(c.Addresses) == 0 {
return errMemcachedConfigNoAddrs
}

Expand Down Expand Up @@ -429,7 +429,7 @@ func (c *memcachedClient) resolveAddrs() error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

c.dnsProvider.Resolve(ctx, c.config.Addrs)
c.dnsProvider.Resolve(ctx, c.config.Addresses)

// Fail in case no server address is resolved.
servers := c.dnsProvider.Addresses()
Expand Down
18 changes: 9 additions & 9 deletions pkg/cacheutil/memcached_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func TestMemcachedClientConfig_validate(t *testing.T) {
}{
"should pass on valid config": {
config: MemcachedClientConfig{
Addrs: []string{"127.0.0.1:11211"},
Addresses: []string{"127.0.0.1:11211"},
},
expected: nil,
},
"should fail on no addrs": {
"should fail on no addresses": {
config: MemcachedClientConfig{
Addrs: []string{},
Addresses: []string{},
},
expected: errMemcachedConfigNoAddrs,
},
Expand Down Expand Up @@ -57,15 +57,15 @@ func TestNewMemcachedClient(t *testing.T) {

// Should instance a memcached client with minimum YAML config.
conf = []byte(`
addrs:
addresses:
- 127.0.0.1:11211
- 127.0.0.2:11211
`)
cache, err = NewMemcachedClient(log.NewNopLogger(), "test", conf, nil)
testutil.Ok(t, err)
defer cache.Stop()

testutil.Equals(t, []string{"127.0.0.1:11211", "127.0.0.2:11211"}, cache.config.Addrs)
testutil.Equals(t, []string{"127.0.0.1:11211", "127.0.0.2:11211"}, cache.config.Addresses)
testutil.Equals(t, defaultMemcachedClientConfig.Timeout, cache.config.Timeout)
testutil.Equals(t, defaultMemcachedClientConfig.MaxIdleConnections, cache.config.MaxIdleConnections)
testutil.Equals(t, defaultMemcachedClientConfig.MaxAsyncConcurrency, cache.config.MaxAsyncConcurrency)
Expand All @@ -76,7 +76,7 @@ addrs:

// Should instance a memcached client with configured YAML config.
conf = []byte(`
addrs:
addresses:
- 127.0.0.1:11211
- 127.0.0.2:11211
timeout: 1s
Expand All @@ -91,7 +91,7 @@ dns_provider_update_interval: 1s
testutil.Ok(t, err)
defer cache.Stop()

testutil.Equals(t, []string{"127.0.0.1:11211", "127.0.0.2:11211"}, cache.config.Addrs)
testutil.Equals(t, []string{"127.0.0.1:11211", "127.0.0.2:11211"}, cache.config.Addresses)
testutil.Equals(t, 1*time.Second, cache.config.Timeout)
testutil.Equals(t, 1, cache.config.MaxIdleConnections)
testutil.Equals(t, 1, cache.config.MaxAsyncConcurrency)
Expand All @@ -106,7 +106,7 @@ func TestMemcachedClient_SetAsync(t *testing.T) {

ctx := context.Background()
config := defaultMemcachedClientConfig
config.Addrs = []string{"127.0.0.1:11211"}
config.Addresses = []string{"127.0.0.1:11211"}
backendMock := newMemcachedClientBackendMock()

client, err := prepare(config, backendMock)
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestMemcachedClient_GetMulti(t *testing.T) {
t.Run(testName, func(t *testing.T) {
ctx := context.Background()
config := defaultMemcachedClientConfig
config.Addrs = []string{"127.0.0.1:11211"}
config.Addresses = []string{"127.0.0.1:11211"}
config.MaxGetMultiBatchSize = testData.maxBatchSize
config.MaxGetMultiConcurrency = testData.maxConcurrency

Expand Down

0 comments on commit f1482f2

Please sign in to comment.