-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from m-barthelemy/feature/3.0.0-beta1
Feature/3.0.0 beta1
- Loading branch information
Showing
10 changed files
with
124 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Foundation | ||
import Fluent | ||
import Queues | ||
|
||
extension FieldKey { | ||
static var payload: Self { "payload" } | ||
static var maxRetryCount: Self { "max_retries" } | ||
static var attempts: Self { "attempt" } | ||
static var delayUntil: Self { "delay_until" } | ||
static var queuedAt: Self { "queued_at" } | ||
static var jobName: Self { "job_name" } | ||
} | ||
|
||
/// Handles storage of a `JobData` into the database | ||
final class JobDataModel: Fields { | ||
required init() {} | ||
|
||
/// The job data to be encoded. | ||
@Field(key: .payload) | ||
var payload: [UInt8] | ||
|
||
/// The maxRetryCount for the `Job`. | ||
@Field(key: .maxRetryCount) | ||
var maxRetryCount: Int | ||
|
||
/// The number of attempts made to run the `Job`. | ||
@Field(key: .attempts) | ||
var attempts: Int? | ||
|
||
/// A date to execute this job after | ||
@OptionalField(key: .delayUntil) | ||
var delayUntil: Date? | ||
|
||
/// The date this job was queued | ||
@Field(key: .queuedAt) | ||
var queuedAt: Date | ||
|
||
/// The name of the `Job` | ||
@Field(key: .jobName) | ||
var jobName: String | ||
|
||
init(jobData: JobData) { | ||
self.payload = jobData.payload | ||
self.maxRetryCount = jobData.maxRetryCount | ||
self.attempts = jobData.attempts | ||
self.delayUntil = jobData.delayUntil | ||
self.jobName = jobData.jobName | ||
self.queuedAt = jobData.queuedAt | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.