[#735] policer: Allow to provide metrics from the outside
Some checks failed
DCO action / DCO (pull_request) Successful in 3m9s
Vulncheck / Vulncheck (pull_request) Successful in 3m28s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Build / Build Components (1.20) (pull_request) Successful in 4m35s
Tests and linters / Lint (pull_request) Successful in 7m19s
Tests and linters / Tests with -race (pull_request) Failing after 9m47s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m0s
Tests and linters / Tests (1.20) (pull_request) Successful in 11m19s
Tests and linters / Staticcheck (pull_request) Successful in 11m4s
Some checks failed
DCO action / DCO (pull_request) Successful in 3m9s
Vulncheck / Vulncheck (pull_request) Successful in 3m28s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Build / Build Components (1.20) (pull_request) Successful in 4m35s
Tests and linters / Lint (pull_request) Successful in 7m19s
Tests and linters / Tests with -race (pull_request) Failing after 9m47s
Tests and linters / Tests (1.21) (pull_request) Successful in 8m0s
Tests and linters / Tests (1.20) (pull_request) Successful in 11m19s
Tests and linters / Staticcheck (pull_request) Successful in 11m4s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
5e229dc248
commit
aca11d7474
2 changed files with 12 additions and 0 deletions
|
@ -3,3 +3,7 @@ package policer
|
|||
type MetricsRegister interface {
|
||||
IncProcessedObjects()
|
||||
}
|
||||
|
||||
type noopMetrics struct{}
|
||||
|
||||
func (noopMetrics) IncProcessedObjects() {}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue