fix_: fix ticker in metrics
Create ticker in Start() instead of one global in service Fix #5548
This commit is contained in:
parent
0456dcef8b
commit
8bb0bb0b3c
|
@ -33,6 +33,7 @@ type MetricService struct {
|
||||||
done chan bool
|
done chan bool
|
||||||
started bool
|
started bool
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
interval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultMetricService(db *sql.DB) *MetricService {
|
func NewDefaultMetricService(db *sql.DB) *MetricService {
|
||||||
|
@ -45,7 +46,7 @@ func NewMetricService(repository MetricRepository, processor common.MetricProces
|
||||||
return &MetricService{
|
return &MetricService{
|
||||||
repository: repository,
|
repository: repository,
|
||||||
processor: processor,
|
processor: processor,
|
||||||
ticker: time.NewTicker(interval),
|
interval: interval,
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,7 @@ func (s *MetricService) Start() {
|
||||||
if s.started {
|
if s.started {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
s.ticker = time.NewTicker(s.interval)
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
s.started = true
|
s.started = true
|
||||||
go func() {
|
go func() {
|
||||||
|
|
Loading…
Reference in New Issue