Class MatrixScheduler<T>

Type Parameters

Hierarchy

  • MatrixScheduler

Constructors

  • Construct a scheduler for Matrix. Requires setProcessFunction to be provided with a way of processing events.

    Type Parameters

    Parameters

    • retryAlgorithm: ((event: null | MatrixEvent, attempts: number, err: MatrixError) => number) = MatrixScheduler.RETRY_BACKOFF_RATELIMIT

      Optional. The retry algorithm to apply when determining when to try to send an event again. Defaults to RETRY_BACKOFF_RATELIMIT.

        • (event: null | MatrixEvent, attempts: number, err: MatrixError): number
        • Retries events up to 4 times using exponential backoff. This produces wait times of 2, 4, 8, and 16 seconds (30s total) after which we give up. If the failure was due to a rate limited request, the time specified in the error is waited before being retried.

          See

          retryAlgorithm

          Parameters

          • event: null | MatrixEvent
          • attempts: number

            Number of attempts that have been made, including the one that just failed (ie. starting at 1)

          • err: MatrixError

          Returns number

    • queueAlgorithm: ((event: MatrixEvent) => null | string) = MatrixScheduler.QUEUE_MESSAGES

      Optional. The queuing algorithm to apply when determining which events should be sent before the given event. Defaults to QUEUE_MESSAGES.

        • (event: MatrixEvent): null | string
        • Queues m.room.message events and lets other events continue concurrently.

          See

          queueAlgorithm

          Parameters

          Returns null | string

    Returns MatrixScheduler<T>

Properties

activeQueues: string[] = []
procFn: null | ProcessFunction<T> = null
queueAlgorithm: ((event: MatrixEvent) => null | string) = MatrixScheduler.QUEUE_MESSAGES

Type declaration

    • (event: MatrixEvent): null | string
    • Queues m.room.message events and lets other events continue concurrently.

      See

      queueAlgorithm

      Parameters

      Returns null | string

queues: Record<string, IQueueEntry<T>[]> = {}
retryAlgorithm: ((event: null | MatrixEvent, attempts: number, err: MatrixError) => number) = MatrixScheduler.RETRY_BACKOFF_RATELIMIT

Type declaration

    • (event: null | MatrixEvent, attempts: number, err: MatrixError): number
    • Retries events up to 4 times using exponential backoff. This produces wait times of 2, 4, 8, and 16 seconds (30s total) after which we give up. If the failure was due to a rate limited request, the time specified in the error is waited before being retried.

      See

      retryAlgorithm

      Parameters

      • event: null | MatrixEvent
      • attempts: number

        Number of attempts that have been made, including the one that just failed (ie. starting at 1)

      • err: MatrixError

      Returns number

Methods

  • Retrieve a queue based on an event. The event provided does not need to be in the queue.

    Returns

    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.

    See

    MatrixScheduler.removeEventFromQueue To remove an event from the queue.

    Parameters

    Returns null | MatrixEvent[]

  • Parameters

    • queueName: string

    Returns void

  • Queue an event if it is required and start processing queues.

    Returns

    A promise if the event was queued, which will be resolved or rejected in due time, else null.

    Parameters

    Returns null | Promise<T>

  • Remove this event from the queue. The event is equal to another event if they have the same ID returned from event.getId().

    Returns

    True if this event was removed.

    Parameters

    Returns boolean

  • 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

    • fn: ProcessFunction<T>

      The function that can process events in the queue.

    Returns void

  • Queues m.room.message events and lets other events continue concurrently.

    See

    queueAlgorithm

    Parameters

    Returns null | string

  • Retries events up to 4 times using exponential backoff. This produces wait times of 2, 4, 8, and 16 seconds (30s total) after which we give up. If the failure was due to a rate limited request, the time specified in the error is waited before being retried.

    See

    retryAlgorithm

    Parameters

    • event: null | MatrixEvent
    • attempts: number

      Number of attempts that have been made, including the one that just failed (ie. starting at 1)

    • err: MatrixError

    Returns number

Generated using TypeDoc