policer: Allow to provide metrics from the outside #735

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:fix-policer into master 2023-10-11 13:07:05 +00:00
2 changed files with 12 additions and 0 deletions
Showing only changes of commit aca11d7474 - Show all commits

View file

@ -3,3 +3,7 @@ package policer
type MetricsRegister interface { type MetricsRegister interface {
IncProcessedObjects() IncProcessedObjects()
} }
type noopMetrics struct{}
func (noopMetrics) IncProcessedObjects() {}

View file

@ -81,6 +81,7 @@ func defaultCfg() *cfg {
rebalanceFreq: 1 * time.Second, rebalanceFreq: 1 * time.Second,
sleepDuration: 1 * time.Second, sleepDuration: 1 * time.Second,
evictDuration: 30 * time.Second, evictDuration: 30 * time.Second,
metrics: noopMetrics{},
} }
} }
@ -172,3 +173,10 @@ func WithPool(p *ants.Pool) Option {
c.taskPool = p c.taskPool = p
} }
} }
// WithMetrics returns option to set metrics.
func WithMetrics(m MetricsRegister) Option {
return func(c *cfg) {
c.metrics = m
}
}