Skip to content

Commit

Permalink
style: fixed mispelling words and missing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Oct 19, 2019
1 parent 209e7a4 commit 0627751
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions cache/cache.go
Expand Up @@ -8,6 +8,7 @@ import (
)

const (
// CacheType represents the cache type as a string value
CacheType = "cache"
)

Expand Down
2 changes: 1 addition & 1 deletion cache/cache_test.go
Expand Up @@ -61,7 +61,7 @@ func TestCacheSetWhenErrorOccurs(t *testing.T) {
Hello: "world",
}

storeErr := errors.New("An error has occured while inserting data into store")
storeErr := errors.New("An error has occurred while inserting data into store")

store := &mocksStore.StoreInterface{}
store.On("Set", "9b1ac8a6e8ca8ca9477c0a252eb37756", value, options).
Expand Down
1 change: 1 addition & 0 deletions cache/chain.go
Expand Up @@ -8,6 +8,7 @@ import (
)

const (
// ChainType represents the chain cache type as a string value
ChainType = "chain"
)

Expand Down
4 changes: 2 additions & 2 deletions cache/chain_test.go
Expand Up @@ -141,7 +141,7 @@ func TestChainDeleteWhenError(t *testing.T) {
// Given
// Cache 1
cache1 := &mocksCache.SetterCacheInterface{}
cache1.On("Delete", "my-key").Return(errors.New("An error has occured while deleting key"))
cache1.On("Delete", "my-key").Return(errors.New("An error has occurred while deleting key"))

// Cache 2
cache2 := &mocksCache.SetterCacheInterface{}
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestChainInvalidateWhenError(t *testing.T) {

// Cache 1
cache1 := &mocksCache.SetterCacheInterface{}
cache1.On("Invalidate", options).Return(errors.New("An unexpected error has occured while invalidation data"))
cache1.On("Invalidate", options).Return(errors.New("An unexpected error has occurred while invalidation data"))

// Cache 2
cache2 := &mocksCache.SetterCacheInterface{}
Expand Down
3 changes: 2 additions & 1 deletion cache/loadable.go
Expand Up @@ -7,6 +7,7 @@ import (
)

const (
// LoadableType represents the loadable cache type as a string value
LoadableType = "loadable"
)

Expand Down Expand Up @@ -38,7 +39,7 @@ func (c *LoadableCache) Get(key interface{}) (interface{}, error) {
// Unable to find in cache, try to load it from load function
object, err = c.loadFunc(key)
if err != nil {
log.Printf("An error has occured while trying to load item from load function: %v\n", err)
log.Printf("An error has occurred while trying to load item from load function: %v\n", err)
return object, err
}

Expand Down
4 changes: 2 additions & 2 deletions cache/loadable_test.go
Expand Up @@ -43,7 +43,7 @@ func TestLoadableGetWhenNotAvailableInLoadFunc(t *testing.T) {
cache1.On("Get", "my-key").Return(nil, errors.New("Unable to find in cache 1"))

loadFunc := func(key interface{}) (interface{}, error) {
return nil, errors.New("An error has occured while loading data from custom source")
return nil, errors.New("An error has occurred while loading data from custom source")
}

cache := NewLoadable(loadFunc, cache1)
Expand All @@ -53,7 +53,7 @@ func TestLoadableGetWhenNotAvailableInLoadFunc(t *testing.T) {

// Then
assert.Nil(t, value)
assert.Equal(t, errors.New("An error has occured while loading data from custom source"), err)
assert.Equal(t, errors.New("An error has occurred while loading data from custom source"), err)
}

func TestLoadableGetWhenAvailableInLoadFunc(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions cache/metric.go
Expand Up @@ -6,6 +6,7 @@ import (
)

const (
// MetricType represents the metric cache type as a string value
MetricType = "metric"
)

Expand Down
4 changes: 4 additions & 0 deletions metrics/prometheus.go
Expand Up @@ -13,6 +13,7 @@ var (
cacheCollector *prometheus.GaugeVec = initCacheCollector(namespaceCache)
)

// Prometheus represents the prometheus struct for collecting metrics
type Prometheus struct {
name string
collector *prometheus.GaugeVec
Expand All @@ -31,14 +32,17 @@ func initCacheCollector(namespace string) *prometheus.GaugeVec {
return c
}

// NewPrometheus initializes a new prometheus metric instance
func NewPrometheus(service string) *Prometheus {
return &Prometheus{service, cacheCollector}
}

// Record records a metric in prometheus by specyfing the store name, metric name and value
func (m *Prometheus) Record(store, metric string, value float64) {
m.collector.WithLabelValues(m.name, store, metric).Set(value)
}

// RecordFromCodec records metrics in prometheus by retrieving values from a codec instance
func (m *Prometheus) RecordFromCodec(codec codec.CodecInterface) {
stats := codec.GetStats()
storeType := codec.GetStore().GetType()
Expand Down
4 changes: 3 additions & 1 deletion store/bigcache.go
Expand Up @@ -15,7 +15,9 @@ type BigcacheClientInterface interface {
}

const (
BigcacheType = "bigcache"
// BigcacheType represents the storage type as a string value
BigcacheType = "bigcache"
// BigcacheTagPattern represents the tag pattern to be used as a key in specified storage
BigcacheTagPattern = "gocache_tag_%s"
)

Expand Down
4 changes: 3 additions & 1 deletion store/memcache.go
Expand Up @@ -17,7 +17,9 @@ type MemcacheClientInterface interface {
}

const (
MemcacheType = "memcache"
// MemcacheType represents the storage type as a string value
MemcacheType = "memcache"
// MemcacheTagPattern represents the tag pattern to be used as a key in specified storage
MemcacheTagPattern = "gocache_tag_%s"
)

Expand Down
4 changes: 3 additions & 1 deletion store/redis.go
Expand Up @@ -16,7 +16,9 @@ type RedisClientInterface interface {
}

const (
RedisType = "redis"
// RedisType represents the storage type as a string value
RedisType = "redis"
// RedisTagPattern represents the tag pattern to be used as a key in specified storage
RedisTagPattern = "gocache_tag_%s"
)

Expand Down
6 changes: 4 additions & 2 deletions store/ristretto.go
Expand Up @@ -8,7 +8,9 @@ import (
)

const (
RistrettoType = "ristretto"
// RistrettoType represents the storage type as a string value
RistrettoType = "ristretto"
// RistrettoTagPattern represents the tag pattern to be used as a key in specified storage
RistrettoTagPattern = "gocache_tag_%s"
)

Expand Down Expand Up @@ -58,7 +60,7 @@ func (s *RistrettoStore) Set(key interface{}, value interface{}, options *Option
}

if set := s.client.Set(key, value, options.CostValue()); !set {
err = fmt.Errorf("An error has occured while setting value '%v' on key '%v'", value, key)
err = fmt.Errorf("An error has occurred while setting value '%v' on key '%v'", value, key)
}

if err != nil {
Expand Down

0 comments on commit 0627751

Please sign in to comment.