[#735] policer: Allow to provide metrics from the outside

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
fix/writecache_flush_inf
Evgenii Stratonikov 2023-10-11 15:13:28 +03:00
parent 5e229dc248
commit aca11d7474
2 changed files with 12 additions and 0 deletions

View File

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

View File

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