DigitalWorldScheduler
Defined in: src/scheduler.ts:44
Type Parameters
Section titled “Type Parameters”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DigitalWorldScheduler<
T>(retryAlgorithm?,queueAlgorithm?):DigitalWorldScheduler<T>
Defined in: src/scheduler.ts:91
Construct a scheduler. Requires DigitalWorldScheduler#setProcessFunction to be provided with a way of processing events.
Parameters
Section titled “Parameters”retryAlgorithm?
Section titled “retryAlgorithm?”(event, attempts, err) => number
Optional. The retry algorithm to apply when determining when to try to send an event again. Defaults to DigitalWorldScheduler.RETRY_BACKOFF_RATELIMIT.
queueAlgorithm?
Section titled “queueAlgorithm?”(event) => string | null
Optional. The queuing algorithm to apply when determining which events should be sent before the given event. Defaults to DigitalWorldScheduler.QUEUE_MESSAGES.
Returns
Section titled “Returns”DigitalWorldScheduler<T>
Properties
Section titled “Properties”queueAlgorithm
Section titled “queueAlgorithm”
readonlyqueueAlgorithm: (event) =>string|null=DigitalWorldScheduler.QUEUE_MESSAGES
Defined in: src/scheduler.ts:118
The queuing algorithm to apply to events. This function must be idempotent as
it may be called multiple times with the same event. All queues created are
serviced in a FIFO manner. To send the event ASAP, return null
which will not put this event in a queue. Events that fail to send that form
part of a queue will be removed from the queue and the next event in the
queue will be sent.
Queues m.room.message events and lets other events continue
concurrently.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string | null
queueAlgorithm
event
The event to be sent.
Returns
Section titled “Returns”The name of the queue to put the event into. If a queue with
this name does not exist, it will be created. If this is null,
the event is not put into a queue and will be sent concurrently.
retryAlgorithm
Section titled “retryAlgorithm”
readonlyretryAlgorithm: (event,attempts,err) =>number=DigitalWorldScheduler.RETRY_BACKOFF_RATELIMIT
Defined in: src/scheduler.ts:105
The retry algorithm to apply when retrying events. To stop retrying, return
-1. If this event was part of a queue, it will be removed from
the queue.
Default retry algorithm for the scheduler. Retries events up to 4 times with exponential backoff.
Parameters
Section titled “Parameters”DigitalWorldEvent | null
attempts
Section titled “attempts”number
Number of attempts that have been made, including the one that just failed (ie. starting at 1)
Returns
Section titled “Returns”number
retryAlgorithm
event
The event being retried.
attempts
The number of failed attempts. This will always be >= 1.
err
The most recent error message received when trying to send this event.
Returns
Section titled “Returns”The number of milliseconds to wait before trying again. If
this is 0, the request will be immediately retried. If this is
-1, the event will be marked as
EventStatus.NOT_SENT and will not be retried.
Methods
Section titled “Methods”getQueueForEvent()
Section titled “getQueueForEvent()”getQueueForEvent(
event):DigitalWorldEvent[] |null
Defined in: src/scheduler.ts:130
Retrieve a queue based on an event. The event provided does not need to be in the queue.
Parameters
Section titled “Parameters”An event to get the queue for.
Returns
Section titled “Returns”DigitalWorldEvent[] | null
A shallow copy of events in the queue or null. Modifying this array will not modify the list itself. Modifying events in this array will modify the underlying event in the queue.
DigitalWorldScheduler.removeEventFromQueue To remove an event from the queue.
queueEvent()
Section titled “queueEvent()”queueEvent(
event):Promise<T> |null
Defined in: src/scheduler.ts:182
Queue an event if it is required and start processing queues.
Parameters
Section titled “Parameters”The event that may be queued.
Returns
Section titled “Returns”Promise<T> | null
A promise if the event was queued, which will be resolved or rejected in due time, else null.
removeEventFromQueue()
Section titled “removeEventFromQueue()”removeEventFromQueue(
event):boolean
Defined in: src/scheduler.ts:146
Remove this event from the queue. The event is equal to another event if they have the same ID returned from event.getId().
Parameters
Section titled “Parameters”The event to remove.
Returns
Section titled “Returns”boolean
True if this event was removed.
setProcessFunction()
Section titled “setProcessFunction()”setProcessFunction(
fn):void
Defined in: src/scheduler.ts:171
Set the process function. Required for events in the queue to be processed. If set after events have been added to the queue, this will immediately start processing them.
Parameters
Section titled “Parameters”ProcessFunction<T>
The function that can process events in the queue.
Returns
Section titled “Returns”void
QUEUE_MESSAGES()
Section titled “QUEUE_MESSAGES()”
staticQUEUE_MESSAGES(event):string|null
Defined in: src/scheduler.ts:61
Queues m.room.message events and lets other events continue
concurrently.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”string | null
queueAlgorithm
RETRY_BACKOFF_RATELIMIT()
Section titled “RETRY_BACKOFF_RATELIMIT()”
staticRETRY_BACKOFF_RATELIMIT(event,attempts,err):number
Defined in: src/scheduler.ts:51
Default retry algorithm for the scheduler. Retries events up to 4 times with exponential backoff.
Parameters
Section titled “Parameters”DigitalWorldEvent | null
attempts
Section titled “attempts”number
Number of attempts that have been made, including the one that just failed (ie. starting at 1)
Returns
Section titled “Returns”number
retryAlgorithm