feat: document the queue, close mutation gaps, plain relay errors

- Document delivery semantics, retries and the queue API in the README and OpenAPI
- Add relay.concurrency to the example config
- Test that a relay problem never counts against a member, that the longest-waiting delivery goes first, and the error and limit details
- Show the plain relay error when there is a single batch
This commit is contained in:
tgiachi 2026-11-09 16:04:45 +01:00
commit 6461e77a95
2 changed files with 83 additions and 10 deletions

View file

@ -35,6 +35,7 @@ describe('queue page', () => {
await setup([])
expect(await screen.findByText(/the queue is empty/i)).toBeInTheDocument()
expect(screen.getByText('Pending').nextElementSibling).toHaveTextContent('0')
expect(screen.getByText('Oldest').nextElementSibling).toHaveTextContent('—')
})
it('shows totals and each delivery, failing ones with their error', async () => {
@ -54,6 +55,19 @@ describe('queue page', () => {
expect(screen.getByText('Oldest').nextElementSibling).toHaveTextContent('2030-01-01 00:00 UTC')
})
it('says how many deliveries are not listed when the server caps the list', async () => {
const state = installFakeApi(newState({ queue: [item(1), item(2), item(3)], queueLimit: 2 }))
renderApp('/queue', { token: 'good' })
expect(await screen.findByText(/showing 2 of 3 deliveries/i)).toBeInTheDocument()
expect(state.queue).toHaveLength(3)
})
it('does not mention a cap when everything is listed', async () => {
await setup([item(1), item(2)])
await screen.findByText('user1@example.com')
expect(screen.queryByText(/showing/i)).not.toBeInTheDocument()
})
it('refreshes on demand', async () => {
const { user, state } = await setup([item(1)])
await screen.findByText('user1@example.com')

View file

@ -9,6 +9,8 @@ export interface FakeState {
held: Record<number, Held[]>
archive: Record<number, Message[]>
queue: QueueItem[]
/** Like the server, the queue listing is capped. */
queueLimit: number
nextId: number
/** Every request seen, as "METHOD /path". */
calls: string[]
@ -17,7 +19,7 @@ export interface FakeState {
}
export function newState(overrides: Partial<FakeState> = {}): FakeState {
return { token: 'good', lists: [], members: {}, held: {}, archive: {}, queue: [], nextId: 100, calls: [], fail: {}, ...overrides }
return { token: 'good', lists: [], members: {}, held: {}, archive: {}, queue: [], queueLimit: 100, nextId: 100, calls: [], fail: {}, ...overrides }
}
export function aList(over: Partial<List> = {}): List {
@ -64,7 +66,7 @@ export function installFakeApi(state: FakeState) {
let m: RegExpMatchArray | null
if (path === '/queue' && method === 'GET') {
const items = [...state.queue].sort((a, b) => b.attempts - a.attempts)
const items = [...state.queue].sort((a, b) => b.attempts - a.attempts).slice(0, state.queueLimit)
const retrying = state.queue.filter((i) => i.attempts > 0).length
const oldest = state.queue.map((i) => i.created_at).sort()[0] ?? null
return json(200, { pending: state.queue.length, retrying, oldest, items })