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
JobPersisterDeclaration
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 theErrormust be provided.Important
If thecompletionis called with anError, and theJobQueuehas aJobRetryStrategy, 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
jobThe QueueJob to be processed
completionThe block to be called when the job has completed processing. The function must be called and should be provided the original
jobthat was provided to the processor. If the JobProcessor fails to process thejob, then the JobProcessor must provide anErrorto the receiver.
View on GitHub
AnyJobProcessor Class Reference