Search Results for

    Show / Hide Table of Contents

    Interface IJobStorageProvider<TStorageRecord>

    interface for defining the contract of a job storage provider

    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public interface IJobStorageProvider<TStorageRecord> where TStorageRecord : IJobStorageRecord
    Type Parameters
    Name Description
    TStorageRecord

    the type of job storage record of this storage provider

    Methods

    CancelJobAsync(Guid, CancellationToken)

    either delete the job storage record from the db using the supplied tracking id or update the IsComplete field to true with a partial update operation.

    Declaration
    Task CancelJobAsync(Guid trackingId, CancellationToken ct)
    Parameters
    Type Name Description
    Guid trackingId

    the TrackingID of the job to be cancelled

    CancellationToken ct

    cancellation token

    Returns
    Type Description
    Task

    GetNextBatchAsync(PendingJobSearchParams<TStorageRecord>)

    fetch the next pending batch of job storage records that need to be processed, with the supplied search parameters.

    Declaration
    Task<IEnumerable<TStorageRecord>> GetNextBatchAsync(PendingJobSearchParams<TStorageRecord> parameters)
    Parameters
    Type Name Description
    PendingJobSearchParams<TStorageRecord> parameters

    use these supplied search parameters to find the next batch of job records from your database

    Returns
    Type Description
    Task<IEnumerable<TStorageRecord>>

    MarkJobAsCompleteAsync(TStorageRecord, CancellationToken)

    mark the job storage record as complete by either replacing the entity on storage with the supplied instance or simply update the IsComplete field to true with a partial update operation.

    Declaration
    Task MarkJobAsCompleteAsync(TStorageRecord r, CancellationToken ct)
    Parameters
    Type Name Description
    TStorageRecord r

    the job storage record to mark as complete

    CancellationToken ct

    cancellation token

    Returns
    Type Description
    Task

    OnHandlerExecutionFailureAsync(TStorageRecord, Exception, CancellationToken)

    this will only be triggered when a command handler (ICommandHandler<TCommand>) associated with a command throws an exception. If you've set an execution time limit for the command, the thrown exception would be of type OperationCanceledException.

    when a job/command execution fails, it will be retried immediately. the failed job will be fetched again with the next batch of pending jobs. if one or more jobs keep failing repeatedly, it may cause the whole queue to get stuck in a retry loop preventing it from progressing.

    to prevent this from happening and allow other jobs to be given a chance at execution, you can reschedule failed jobs to be re-attempted at a future time instead. simply update the ExecuteAfter property to a future date/time and save the entity to the database (or do a partial update of only that property value).

    Declaration
    Task OnHandlerExecutionFailureAsync(TStorageRecord r, Exception exception, CancellationToken ct)
    Parameters
    Type Name Description
    TStorageRecord r

    the job that failed to execute successfully

    Exception exception

    the exception that was thrown

    CancellationToken ct

    cancellation token

    Returns
    Type Description
    Task

    PurgeStaleJobsAsync(StaleJobSearchParams<TStorageRecord>)

    this method will be called hourly. implement this method to delete stale records (completed or expired) from storage. you can safely delete the completed records. the incomplete & expired records can be moved to some other location (dead-letter-queue maybe) or for inspection by a human. or if you'd like to retry expired events, update the ExpireOn field to a future date/time.

    Declaration
    Task PurgeStaleJobsAsync(StaleJobSearchParams<TStorageRecord> parameters)
    Parameters
    Type Name Description
    StaleJobSearchParams<TStorageRecord> parameters

    use these supplied search parameters to find stale job records from your database

    Returns
    Type Description
    Task

    StoreJobAsync(TStorageRecord, CancellationToken)

    store the job storage record however you please. ideally on a nosql database.

    Declaration
    Task StoreJobAsync(TStorageRecord r, CancellationToken ct)
    Parameters
    Type Name Description
    TStorageRecord r

    the job storage record which contains the actual command object as well as some metadata

    CancellationToken ct
    Returns
    Type Description
    Task
    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX