Module: scheduler

This is an internal module which manages queuing, scheduling and retrying of requests.
Source:

module:scheduler

The MatrixScheduler class.
Source:

Classes

MatrixScheduler

Type Definitions

processFn(event) → {Promise}

The function to invoke to process (send) events in the queue.
Parameters:
Name Type Description
event MatrixEvent The event to send.
Source:
Returns:
Resolved/rejected depending on the outcome of the request.
Type
Promise

queueAlgorithm(event) → {string}

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.
Parameters:
Name Type Description
event MatrixEvent The event to be sent.
Source:
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.
Type
string

retryAlgorithm(event, attempts, err) → {Number}

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.
Parameters:
Name Type Description
event MatrixEvent The event being retried.
attempts Number The number of failed attempts. This will always be >= 1.
err MatrixError The most recent error message received when trying to send this event.
Source:
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 module:models/event.EventStatus.NOT_SENT and will not be retried.
Type
Number