Skip to content

Commit

Permalink
Fixes to memcache support (#1628)
Browse files Browse the repository at this point in the history
* Fix errors discovered in dev

* Log an error rather than aborting when memcache doesn't resolve
* Initialize map correctly

* Review tweaks
  • Loading branch information
jml authored and tomwilkie committed Jul 4, 2016
1 parent 682edd3 commit 96520d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/multitenant/memcache_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type MemcacheClient struct {

// NewMemcacheClient creates a new MemcacheClient that gets its server list
// from SRV and updates the server list on a regular basis.
func NewMemcacheClient(host string, timeout time.Duration, service string, updateInterval time.Duration, expiration int32) (*MemcacheClient, error) {
func NewMemcacheClient(host string, timeout time.Duration, service string, updateInterval time.Duration, expiration int32) *MemcacheClient {
var servers memcache.ServerList
client := memcache.NewFromSelector(&servers)
client.Timeout = timeout
Expand All @@ -70,12 +70,12 @@ func NewMemcacheClient(host string, timeout time.Duration, service string, updat
}
err := newClient.updateMemcacheServers()
if err != nil {
return nil, err
log.Errorf("Error setting memcache servers to '%v': %v", host, err)
}

newClient.wait.Add(1)
go newClient.updateLoop(updateInterval)
return newClient, nil
return newClient
}

// Stop the memcache client.
Expand Down Expand Up @@ -169,7 +169,7 @@ func (c *MemcacheClient) FetchReports(keys []string) (map[string]report.Report,
}(key)
}

var reports map[string]report.Report
reports := map[string]report.Report{}
for i := 0; i < len(keys)-len(missing); i++ {
r := <-ch
if r.report == nil {
Expand Down
13 changes: 1 addition & 12 deletions prog/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,10 @@ func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHo
s3Store := multitenant.NewS3Client(s3Config, bucketName)
var memcacheClient *multitenant.MemcacheClient
if memcachedHostname != "" {
memcacheClient, err = multitenant.NewMemcacheClient(
memcacheClient = multitenant.NewMemcacheClient(
memcachedHostname, memcachedTimeout, memcachedService,
memcacheUpdateInterval, memcacheExpiration,
)
if err != nil {
// TODO(jml): Ideally, we wouldn't abort here, we would instead
// log errors when we try to use the memcache & fail to do so, as
// aborting here introduces ordering dependencies into our
// deployment.
//
// Note: this error only happens when either the memcachedHost
// or any of the SRV records that it points to fail to
// resolve.
return nil, err
}
}
awsCollector, err := multitenant.NewAWSCollector(
multitenant.AWSCollectorConfig{
Expand Down

0 comments on commit 96520d7

Please sign in to comment.