Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 9x 1x 1x 1x | import { MessageQueue } from '@/types/capabilities/MessageQueue'
/**
* @class
*
* A queue that accepts nothing.
*
* @remarks
* Returns `false` from both enqueue methods, which
* [`MessageQueue`](../../types/capabilities/MessageQueue.ts) defines as "the follow-up work was not
* scheduled" rather than as a failure — so a caller keeps succeeding at the
* thing it was actually asked to do and decides for itself whether the missed
* follow-up is worth a log line.
*
* Worth being deliberate about: swapping this in silently drops background
* work. That is correct when the work is genuinely optional, and wrong when a
* queued message is the only record that something must happen later.
*
* @typeParam T The message body, never read.
* @typeParam TRuntime The runtime handle, ignored throughout.
*
* @author Bayu Dwiyan Satria
* @version 1.0.0
* @since 1.0.0
*/
export class NoopMessageQueue<T = unknown, TRuntime = unknown> implements MessageQueue<T, TRuntime> {
/**
* Discards the message.
*
* @returns `false`.
*/
public async enqueue(): Promise<boolean> {
return false
}
/**
* Discards the batch.
*
* @returns `false`.
*/
public async enqueueAll(): Promise<boolean> {
return false
}
/**
* Never available.
*
* @returns `false`.
*/
public isAvailable(): boolean {
return false
}
}
|