diff --git a/docs/components/store.md b/docs/components/store.md index aa93f7c00f..c25512993c 100644 --- a/docs/components/store.md +++ b/docs/components/store.md @@ -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 @@ -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**: diff --git a/pkg/cacheutil/memcached_client.go b/pkg/cacheutil/memcached_client.go index 203bd321ca..91d4552dd1 100644 --- a/pkg/cacheutil/memcached_client.go +++ b/pkg/cacheutil/memcached_client.go @@ -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, @@ -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"` @@ -95,7 +95,7 @@ type MemcachedClientConfig struct { } func (c *MemcachedClientConfig) validate() error { - if len(c.Addrs) == 0 { + if len(c.Addresses) == 0 { return errMemcachedConfigNoAddrs } @@ -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() diff --git a/pkg/cacheutil/memcached_client_test.go b/pkg/cacheutil/memcached_client_test.go index f73f1a27ce..a1f77fe282 100644 --- a/pkg/cacheutil/memcached_client_test.go +++ b/pkg/cacheutil/memcached_client_test.go @@ -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, }, @@ -57,7 +57,7 @@ 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 `) @@ -65,7 +65,7 @@ addrs: 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) @@ -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 @@ -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) @@ -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) @@ -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