client.go 652 B

123456789101112131415161718192021222324252627
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package memcachedreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver"
  4. import (
  5. "net"
  6. "time"
  7. "github.com/grobie/gomemcache/memcache"
  8. )
  9. type client interface {
  10. Stats() (map[net.Addr]memcache.Stats, error)
  11. }
  12. type newMemcachedClientFunc func(endpoint string, timeout time.Duration) (client, error)
  13. func newMemcachedClient(endpoint string, timeout time.Duration) (client, error) {
  14. newClient, err := memcache.New(endpoint)
  15. if err != nil {
  16. return nil, err
  17. }
  18. newClient.Timeout = timeout
  19. return newClient, nil
  20. }