AnyJobPersister
public class AnyJobPersister<HandlingJob: QueueJob>: JobPersister
A type-erased wrapper for a JobPersister. Use this if you need to define an argument of a JobPersister, or if you need to store a JobPersister as a property.
Examples:
struct MyJobType: QueueJob { ... }
var persister: AnyJobPersister<MyJobType>
func someFunc(takingPersister: 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: JobPersister>(_ persister: P) where P.JobType == HandlingJob
-
Will save the jobs to a permanent destination using the internal
JobPersister
Throws
If there’s an error persisting 1 or more of the jobs.Declaration
Swift
public func persist(_ jobs: [HandlingJob]) throws
Parameters
jobs
The jobs to persist
-
Deletes the job’s persisted data using the internal
JobPersister
Throws
If there’s an error deleting the job’s persisted data.Declaration
Swift
public func delete(_ job: HandlingJob) throws
Parameters
job
The job whose data is to be deleted
-
Loads all the Jobs from their permanent source using the internal
JobPersister
Throws
If there’s an error loading and deserializing 1 or more jobs from their persisted data.Declaration
Swift
public func load() throws -> [HandlingJob]
Return Value
An array of deserialized jobs.
-
Deletes all jobs from the persisted location using the internal
JobPersister
Declaration
Swift
public func clear(completion: ((Error?) -> Void)?)
Parameters
completion
An optional callback to be called after the clearing has completed.