Skip to content

Commit

Permalink
feat: make name field of Cache private
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <[email protected]>
  • Loading branch information
gleich committed Sep 10, 2024
1 parent d357f16 commit 93d3d84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

type Cache[T any] struct {
Name string
name string
mutex sync.RWMutex
data T
updated time.Time
Expand All @@ -28,7 +28,7 @@ type Cache[T any] struct {

func NewCache[T any](name string, data T) *Cache[T] {
cache := Cache[T]{
Name: name,
name: name,
updateCounter: promauto.NewCounter(prometheus.CounterOpts{
Name: fmt.Sprintf("cache_%s_updates", name),
Help: fmt.Sprintf(`The total number of times the cache "%s" has been updated`, name),
Expand Down Expand Up @@ -91,7 +91,7 @@ func (c *Cache[T]) Update(data T) {
c.updateCounter.Inc()
metrics.CacheUpdates.Inc()
c.persistToFile()
lumber.Done(strings.ToUpper(c.Name), "cache updated")
lumber.Done(strings.ToUpper(c.name), "cache updated")
}
}

Expand All @@ -101,7 +101,7 @@ func (c *Cache[T]) StartPeriodicUpdate(updateFunc func() (T, error), interval ti
for range ticker.C {
data, err := updateFunc()
if err != nil {
lumber.ErrorMsg("updating cache", c.Name, "failed")
lumber.ErrorMsg("updating cache", c.name, "failed")
continue
}
c.Update(data)
Expand Down

0 comments on commit 93d3d84

Please sign in to comment.