Skip to content

Commit

Permalink
Fix: app/stats.Manager does not implement features/stats.Manager (v2f…
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyalsoldier authored Sep 9, 2020
1 parent 16fe0b0 commit d7c99c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ func (m *Manager) RegisterCounter(name string) (stats.Counter, error) {
return c, nil
}

// UnregisterCounter implements stats.Manager.
func (m *Manager) UnregisterCounter(name string) error {
m.access.Lock()
defer m.access.Unlock()
if _, found := m.counters[name]; !found {
return newError("Counter ", name, " was not found.")
}
newError("remove counter ", name).AtDebug().WriteToLog()
delete(m.counters, name)
return nil
}

// GetCounter implements stats.Manager.
func (m *Manager) GetCounter(name string) stats.Counter {
m.access.RLock()
Expand Down
6 changes: 6 additions & 0 deletions features/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Manager interface {

// RegisterCounter registers a new counter to the manager. The identifier string must not be empty, and unique among other counters.
RegisterCounter(string) (Counter, error)
UnregisterCounter(string) error
// GetCounter returns a counter by its identifier.
GetCounter(string) Counter

Expand Down Expand Up @@ -87,6 +88,11 @@ func (NoopManager) RegisterCounter(string) (Counter, error) {
return nil, newError("not implemented")
}

// UnregisterCounter implements Manager.
func (NoopManager) UnregisterCounter(string) error {
return newError("not implemented")
}

// GetCounter implements Manager.
func (NoopManager) GetCounter(string) Counter {
return nil
Expand Down

0 comments on commit d7c99c9

Please sign in to comment.