1
0
Fork 0
forked from forgejo/forgejo

Queue: Add monitoring

This commit is contained in:
Andrew Thornton 2019-12-07 16:48:21 +00:00
parent 85d1a7f7d2
commit 2927bc6fe5
No known key found for this signature in database
GPG key ID: 3CDE74631F13A748
13 changed files with 541 additions and 20 deletions

View file

@ -85,7 +85,7 @@ func NewPersistableChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (
return nil, ErrInvalidConfiguration{cfg: cfg}
}
return &PersistableChannelQueue{
queue := &PersistableChannelQueue{
ChannelQueue: channelQueue.(*ChannelQueue),
delayedStarter: delayedStarter{
cfg: levelCfg,
@ -95,7 +95,9 @@ func NewPersistableChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (
name: config.Name,
},
closed: make(chan struct{}),
}, nil
}
_ = GetManager().Add(queue, PersistableChannelQueueType, config, exemplar, nil, nil)
return queue, nil
}
// Name returns the name of this queue
@ -127,7 +129,9 @@ func (p *PersistableChannelQueue) Run(atShutdown, atTerminate func(context.Conte
// Just run the level queue - we shut it down later
go p.internal.Run(func(_ context.Context, _ func()) {}, func(_ context.Context, _ func()) {})
go p.ChannelQueue.pool.addWorkers(p.ChannelQueue.pool.baseCtx, p.workers)
go func() {
_ = p.ChannelQueue.pool.AddWorkers(p.workers, 0)
}()
<-p.closed
p.ChannelQueue.pool.cancel()