1
0
Fork 0
forked from forgejo/forgejo

Queue: Add name variable to queues

This commit is contained in:
Andrew Thornton 2019-12-07 16:46:36 +00:00
parent e6ebb47299
commit 85d1a7f7d2
No known key found for this signature in database
GPG key ID: 3CDE74631F13A748
6 changed files with 52 additions and 21 deletions

View file

@ -24,6 +24,7 @@ type ChannelQueueConfiguration struct {
BlockTimeout time.Duration
BoostTimeout time.Duration
BoostWorkers int
Name string
}
// ChannelQueue implements
@ -31,6 +32,7 @@ type ChannelQueue struct {
pool *WorkerPool
exemplar interface{}
workers int
name string
}
// NewChannelQueue create a memory channel queue
@ -59,16 +61,17 @@ func NewChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, erro
},
exemplar: exemplar,
workers: config.Workers,
name: config.Name,
}, nil
}
// Run starts to run the queue
func (c *ChannelQueue) Run(atShutdown, atTerminate func(context.Context, func())) {
atShutdown(context.Background(), func() {
log.Warn("ChannelQueue is not shutdownable!")
log.Warn("ChannelQueue: %s is not shutdownable!", c.name)
})
atTerminate(context.Background(), func() {
log.Warn("ChannelQueue is not terminatable!")
log.Warn("ChannelQueue: %s is not terminatable!", c.name)
})
c.pool.addWorkers(c.pool.baseCtx, c.workers)
}