Postbox

interface Postbox

Postbox is the storage mechanism for requests that are to be processed asynchronously.

Inheritors

Types

Link copied to clipboard
data class PendingRequest(val requestId: RequestId, val request: Request, val processingTime: Instant, val failures: Int)

Functions

Link copied to clipboard
abstract fun markDead(requestId: RequestId, response: Response? = null): Result<Unit, PostboxError>

Mark a request as permanently failed (dead) with an optional response.

Link copied to clipboard
abstract fun markFailed(requestId: RequestId, delayReprocessing: Duration, response: Response?): Result<Unit, PostboxError>

Mark a request as failed with the given delay for reprocessing and an optional response.

Link copied to clipboard
abstract fun markProcessed(requestId: RequestId, response: Response): Result<Unit, PostboxError>

Mark a request as processed with the given response.

Link copied to clipboard
abstract fun pendingRequests(batchSize: Int, atTime: Instant): List<Postbox.PendingRequest>

Retrieve all pending requests. Those are the ones that have not been marked as processed or dead yet.

Link copied to clipboard
abstract fun status(requestId: RequestId): Result<RequestProcessingStatus, PostboxError>

Retrieve the status of a request.

Link copied to clipboard
abstract fun store(requestId: RequestId, request: Request): Result<RequestProcessingStatus, PostboxError>

Store a request in the Postbox for later processing.