A ping upload manager. Manages a queue of pending pings to upload.

Observes the pings database and whenever that is updated the newly recorded ping is enqueued.

Constructors

Properties

pingsDatabase: default
policy: default = ...
processing: Set<string>
queue: QueuedPing[]
rateLimiter: default = ...
recoverableFailureCount: number = 0
waitAttemptCount: number = 0
worker: default

Methods

  • Clears the pending pings queue.

    Important

    This will drop pending pings still enqueued. Only the deletion-request ping will still be processed.

    Returns void

    A promise which resolves once the clearing is complete and all upload attempts have been exhausted.

  • Enqueues a new ping at the end of the queue.

    Will not enqueue if a ping with the same identifier is already enqueued or is currently being processed.

    Parameters

    Returns void

  • Processes the response from an attempt to upload a ping.

    Based on the HTTP status of said response, the possible outcomes are:

    200 - 299 Success** Any status on the 2XX range is considered a successful upload, which means the corresponding ping file can be deleted.

    Known 2XX status: 200 - OK. Request accepted into the pipeline.

    400 - 499 Unrecoverable error** Any status on the 4XX range means something our client did is not correct. It is unlikely that the client is going to recover from this by retrying, so in this case the corresponding ping file can also be deleted.

    Known 4XX status: 404 - not found - POST/PUT to an unknown namespace 405 - wrong request type (anything other than POST/PUT) 411 - missing content-length header 413 - request body too large Note that if we have badly-behaved clients that retry on 4XX, we should send back 202 on body/path too long). 414 - request path too long (See above)

    Any other error** For any other error, a warning is logged and the ping is re-enqueued.

    Known other errors: 500 - internal error

    Parameters

    • ping: QueuedPing

      The ping that was just uploaded.

    • response: UploadResult

      The response of a ping upload attempt.

    Returns void

    Whether or not to retry the upload attempt.

  • Enqueues a new ping and trigger uploading of enqueued pings.

    This function is called by the PingDatabase every time a new ping is added to the database or when the database is being scanned.

    Parameters

    • identifier: string

      The id of the ping that was just recorded.

    • ping: PingInternalRepresentation

      An object containing the newly recorded ping path, payload and optionally headers.

    Returns void

Generated using TypeDoc