InMemoryPostbox

class InMemoryPostbox(val timeSource: TimeSource) : Postbox(source)

Constructors

Link copied to clipboard
constructor(timeSource: TimeSource)

Properties

Link copied to clipboard
val timeSource: TimeSource

Functions

Link copied to clipboard
open override fun claim(batchSize: Int, atTime: Instant, lease: Duration): List<Postbox.PendingRequest>

Atomically claim a batch of due requests for processing, marking them as RequestProcessingStatus.Processing until either they are finalised via markProcessed, markFailed or markDead, or until the given lease expires (after which they can be reclaimed by a subsequent call).

Link copied to clipboard
open override 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
open override 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
open override fun markProcessed(requestId: RequestId, response: Response): Result<Unit, PostboxError>

Mark a request as processed with the given response.

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

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

Link copied to clipboard

Retrieve the status of a request.

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

Store a request in the Postbox for later processing.