From c7fa7af03f058a2a744c9cba9996638afd8a3d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Barth=C3=A9lemy?= Date: Sun, 5 Apr 2020 07:08:54 +0800 Subject: [PATCH] FUCKING Xcode --- Sources/QueuesFluentDriver/FluentQueue.swift | 5 -- Sources/QueuesFluentDriver/JobModel.swift | 54 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 Sources/QueuesFluentDriver/JobModel.swift diff --git a/Sources/QueuesFluentDriver/FluentQueue.swift b/Sources/QueuesFluentDriver/FluentQueue.swift index 2e71163..1847cab 100644 --- a/Sources/QueuesFluentDriver/FluentQueue.swift +++ b/Sources/QueuesFluentDriver/FluentQueue.swift @@ -1,12 +1,8 @@ import Foundation import Queues import Fluent -import FluentKit import SQLKit -import FluentMySQLDriver -import FluentPostgresDriver - struct FluentQueue { let database: Database let context: QueueContext @@ -119,7 +115,6 @@ extension FluentQueue: Queue { } } - } enum QueuesFluentError: Error { diff --git a/Sources/QueuesFluentDriver/JobModel.swift b/Sources/QueuesFluentDriver/JobModel.swift new file mode 100644 index 0000000..ca578bd --- /dev/null +++ b/Sources/QueuesFluentDriver/JobModel.swift @@ -0,0 +1,54 @@ +import Foundation +import Fluent + +enum JobState: String, Codable, CaseIterable { + /// Job created but should NOT be picked up for execution yet + case initial + /// Ready to be oicked up for execution + case pending + case processing + /// Executed, regardless if it was successful or not + case completed +} + +class JobModel: Model { + public required init() {} + + /// Properties + public static var schema = "jobs" + + /// The unique Job uuid + @ID(key: .id) + public var id: UUID? + + /// The Job key + @Field(key: "key") + var key: String + + /// The Job data + @Field(key: "data") + var data: Data + + /// The current state of the Job + @Field(key: "state") + var state: JobState + + /// The created timestamp + @Timestamp(key: "created_at", on: .create) + var createdAt: Date? + + /// The updated timestamp + @Timestamp(key: "updated_at", on: .update) + var updatedAt: Date? + + @Timestamp(key: "deleted_at", on: .delete) + var deletedAt: Date? + + + init(id: UUID, key: String, data: Data) { + self.id = id + self.key = key + self.data = data + self.state = .initial + } +}