mirror of
https://github.com/mjl-/mox.git
synced 2025-01-14 01:06:27 +03:00
on admin index page, show number of messages in queue next to link to the queue list
This commit is contained in:
parent
2154392bd8
commit
8bdca09b7b
4 changed files with 30 additions and 2 deletions
|
@ -1447,6 +1447,13 @@ func (Admin) QueueList(ctx context.Context) []queue.Msg {
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueueSize returns the number of messages currently in the outgoing queue.
|
||||||
|
func (Admin) QueueSize(ctx context.Context) int {
|
||||||
|
n, err := queue.Count()
|
||||||
|
xcheckf(ctx, err, "listing messages in queue")
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
// QueueKick initiates delivery of a message from the queue.
|
// QueueKick initiates delivery of a message from the queue.
|
||||||
func (Admin) QueueKick(ctx context.Context, id int64) {
|
func (Admin) QueueKick(ctx context.Context, id int64) {
|
||||||
n, err := queue.Kick(id, "", "")
|
n, err := queue.Kick(id, "", "")
|
||||||
|
|
|
@ -188,7 +188,10 @@ const formatSize = n => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = async () => {
|
const index = async () => {
|
||||||
const domains = await api.Domains()
|
const [domains, queueSize] = await Promise.all([
|
||||||
|
await api.Domains(),
|
||||||
|
await api.QueueSize(),
|
||||||
|
])
|
||||||
|
|
||||||
let fieldset, domain, account, localpart
|
let fieldset, domain, account, localpart
|
||||||
|
|
||||||
|
@ -197,7 +200,7 @@ const index = async () => {
|
||||||
crumbs('Mox Admin'),
|
crumbs('Mox Admin'),
|
||||||
dom.p(
|
dom.p(
|
||||||
dom.a('Accounts', attr({href: '#accounts'})), dom.br(),
|
dom.a('Accounts', attr({href: '#accounts'})), dom.br(),
|
||||||
dom.a('Queue', attr({href: '#queue'})), dom.br(),
|
dom.a('Queue', attr({href: '#queue'})), ' ('+queueSize+')', dom.br(),
|
||||||
),
|
),
|
||||||
dom.h2('Domains'),
|
dom.h2('Domains'),
|
||||||
domains.length === 0 ? box(red, 'No domains') :
|
domains.length === 0 ? box(red, 'No domains') :
|
||||||
|
|
|
@ -552,6 +552,19 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Name": "QueueSize",
|
||||||
|
"Docs": "QueueSize returns the number of messages currently in the outgoing queue.",
|
||||||
|
"Params": [],
|
||||||
|
"Returns": [
|
||||||
|
{
|
||||||
|
"Name": "r0",
|
||||||
|
"Typewords": [
|
||||||
|
"int32"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Name": "QueueKick",
|
"Name": "QueueKick",
|
||||||
"Docs": "QueueKick initiates delivery of a message from the queue.",
|
"Docs": "QueueKick initiates delivery of a message from the queue.",
|
||||||
|
|
|
@ -162,6 +162,11 @@ func List() ([]Msg, error) {
|
||||||
return qmsgs, nil
|
return qmsgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count returns the number of messages in the delivery queue.
|
||||||
|
func Count() (int, error) {
|
||||||
|
return bstore.QueryDB[Msg](queueDB).Count()
|
||||||
|
}
|
||||||
|
|
||||||
// Add a new message to the queue. The queue is kicked immediately to start a
|
// Add a new message to the queue. The queue is kicked immediately to start a
|
||||||
// first delivery attempt.
|
// first delivery attempt.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue