mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-29 09:31:11 -05:00
Add number in queue status to monitor page (#18712)
Add number in queue status to the monitor page so that administrators can assess how much work is left to be done in the queues. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
9444135ff5
commit
4e57bd1d30
6 changed files with 27 additions and 0 deletions
|
@ -84,6 +84,8 @@ type ManagedPool interface {
|
||||||
BoostWorkers() int
|
BoostWorkers() int
|
||||||
// SetPoolSettings sets the user updatable settings for the pool
|
// SetPoolSettings sets the user updatable settings for the pool
|
||||||
SetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration)
|
SetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration)
|
||||||
|
// NumberInQueue returns the total number of items in the pool
|
||||||
|
NumberInQueue() int64
|
||||||
// Done returns a channel that will be closed when the Pool's baseCtx is closed
|
// Done returns a channel that will be closed when the Pool's baseCtx is closed
|
||||||
Done() <-chan struct{}
|
Done() <-chan struct{}
|
||||||
}
|
}
|
||||||
|
@ -427,6 +429,14 @@ func (q *ManagedQueue) SetPoolSettings(maxNumberOfWorkers, boostWorkers int, tim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NumberInQueue returns the number of items in the queue
|
||||||
|
func (q *ManagedQueue) NumberInQueue() int64 {
|
||||||
|
if pool, ok := q.Managed.(ManagedPool); ok {
|
||||||
|
return pool.NumberInQueue()
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
func (l ManagedQueueList) Len() int {
|
func (l ManagedQueueList) Len() int {
|
||||||
return len(l)
|
return len(l)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,13 @@ func (q *ByteFIFOQueue) IsEmpty() bool {
|
||||||
return q.byteFIFO.Len(q.terminateCtx) == 0
|
return q.byteFIFO.Len(q.terminateCtx) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NumberInQueue returns the number in the queue
|
||||||
|
func (q *ByteFIFOQueue) NumberInQueue() int64 {
|
||||||
|
q.lock.Lock()
|
||||||
|
defer q.lock.Unlock()
|
||||||
|
return q.byteFIFO.Len(q.terminateCtx) + q.WorkerPool.NumberInQueue()
|
||||||
|
}
|
||||||
|
|
||||||
// Flush flushes the ByteFIFOQueue
|
// Flush flushes the ByteFIFOQueue
|
||||||
func (q *ByteFIFOQueue) Flush(timeout time.Duration) error {
|
func (q *ByteFIFOQueue) Flush(timeout time.Duration) error {
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -204,6 +204,11 @@ func (p *WorkerPool) NumberOfWorkers() int {
|
||||||
return p.numberOfWorkers
|
return p.numberOfWorkers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NumberInQueue returns the number of items in the queue
|
||||||
|
func (p *WorkerPool) NumberInQueue() int64 {
|
||||||
|
return atomic.LoadInt64(&p.numInQueue)
|
||||||
|
}
|
||||||
|
|
||||||
// MaxNumberOfWorkers returns the maximum number of workers automatically added to the pool
|
// MaxNumberOfWorkers returns the maximum number of workers automatically added to the pool
|
||||||
func (p *WorkerPool) MaxNumberOfWorkers() int {
|
func (p *WorkerPool) MaxNumberOfWorkers() int {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
|
|
|
@ -2820,6 +2820,7 @@ monitor.queue.type = Type
|
||||||
monitor.queue.exemplar = Exemplar Type
|
monitor.queue.exemplar = Exemplar Type
|
||||||
monitor.queue.numberworkers = Number of Workers
|
monitor.queue.numberworkers = Number of Workers
|
||||||
monitor.queue.maxnumberworkers = Max Number of Workers
|
monitor.queue.maxnumberworkers = Max Number of Workers
|
||||||
|
monitor.queue.numberinqueue = Number in Queue
|
||||||
monitor.queue.review = Review Config
|
monitor.queue.review = Review Config
|
||||||
monitor.queue.review_add = Review/Add Workers
|
monitor.queue.review_add = Review/Add Workers
|
||||||
monitor.queue.configuration = Initial Configuration
|
monitor.queue.configuration = Initial Configuration
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.type"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.type"}}</th>
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.exemplar"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.exemplar"}}</th>
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.numberworkers"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.numberworkers"}}</th>
|
||||||
|
<th>{{.i18n.Tr "admin.monitor.queue.numberinqueue"}}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -58,6 +59,7 @@
|
||||||
<td>{{.Type}}</td>
|
<td>{{.Type}}</td>
|
||||||
<td>{{.ExemplarType}}</td>
|
<td>{{.ExemplarType}}</td>
|
||||||
<td>{{$sum := .NumberOfWorkers}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
<td>{{$sum := .NumberOfWorkers}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
||||||
|
<td>{{$sum := .NumberInQueue}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
||||||
<td><a href="{{$.Link}}/queue/{{.QID}}" class="button">{{if lt $sum 0}}{{$.i18n.Tr "admin.monitor.queue.review"}}{{else}}{{$.i18n.Tr "admin.monitor.queue.review_add"}}{{end}}</a>
|
<td><a href="{{$.Link}}/queue/{{.QID}}" class="button">{{if lt $sum 0}}{{$.i18n.Tr "admin.monitor.queue.review"}}{{else}}{{$.i18n.Tr "admin.monitor.queue.review_add"}}{{end}}</a>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.exemplar"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.exemplar"}}</th>
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.numberworkers"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.numberworkers"}}</th>
|
||||||
<th>{{.i18n.Tr "admin.monitor.queue.maxnumberworkers"}}</th>
|
<th>{{.i18n.Tr "admin.monitor.queue.maxnumberworkers"}}</th>
|
||||||
|
<th>{{.i18n.Tr "admin.monitor.queue.numberinqueue"}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
<td>{{.Queue.ExemplarType}}</td>
|
<td>{{.Queue.ExemplarType}}</td>
|
||||||
<td>{{$sum := .Queue.NumberOfWorkers}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
<td>{{$sum := .Queue.NumberOfWorkers}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
||||||
<td>{{if lt $sum 0}}-{{else}}{{.Queue.MaxNumberOfWorkers}}{{end}}</td>
|
<td>{{if lt $sum 0}}-{{else}}{{.Queue.MaxNumberOfWorkers}}{{end}}</td>
|
||||||
|
<td>{{$sum := .Queue.NumberInQueue}}{{if lt $sum 0}}-{{else}}{{$sum}}{{end}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue