AnyJobProcessor

open class AnyJobProcessor<HandlingJob: QueueJob>: JobProcessor

A type-erased wrapper for a JobProcessor. Use this if you need to define an argument of a JobProcessor, or if you need to store a JobProcessor as a property.

Examples:

struct MyJobType: QueueJob { ... }
var persister: AnyJobProcessor<MyJobType>
func someFunc(usingProcessor: AnyJobPersister<MyJobType>)
  • The expected QueueJob type this erasure is wrapping

    Declaration

    Swift

    public typealias JobType = HandlingJob
  • Creates a new wrapper for the given JobPersister

    Declaration

    Swift

    public init<P: JobProcessor>(_ processor: P) where P.JobType == HandlingJob
  • Processes a job of the given type using the internal JobProcessor. If the job fails to process for any reason the Error must be provided.

    Important

    If the completion is called with an Error, and the JobQueue has a JobRetryStrategy, then the job will be requeued. Otherwise the job will be purged from the JobQueue.

    Declaration

    Swift

    public func processJob(_ job: HandlingJob, completion: @escaping ((HandlingJob, Error?) -> Void))

    Parameters

    job

    The QueueJob to be processed

    completion

    The block to be called when the job has completed processing. The function must be called and should be provided the original job that was provided to the processor. If the JobProcessor fails to process the job, then the JobProcessor must provide an Error to the receiver.