Skip to content

Commit

Permalink
Merge pull request #18 from hummingbird-project/metadata-read
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Aug 29, 2024
2 parents e40ea83 + 5070ec1 commit 84dc086
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Sources/Jobs/Scheduler/JobSchedule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ public struct JobSchedule: MutableCollection, Sendable {

init(jobQueue: JobQueue<Driver>, jobSchedule: JobSchedule) async {
self.jobQueue = jobQueue
var jobSchedule = jobSchedule
self.jobSchedule = jobSchedule
}

/// Run Job scheduler
public func run() async throws {
try await self.jobQueue.initializationComplete.waitUntilTriggered()
var jobSchedule = self.jobSchedule
// Update next scheduled date for each job schedule based off the last scheduled date stored
do {
if let date = try await self.jobQueue.getMetadata(.jobScheduleLastDate) {
Expand All @@ -171,15 +177,8 @@ public struct JobSchedule: MutableCollection, Sendable {
} catch {
self.jobQueue.logger.error("Failed to get last scheduled job date.")
}

self.jobSchedule = jobSchedule
}

/// Run Job scheduler
public func run() async throws {
try await self.jobQueue.initializationComplete.waitUntilTriggered()
let scheduledJobSequence = JobSequence(
jobSchedule: self.jobSchedule,
jobSchedule: jobSchedule,
logger: self.jobQueue.logger
)
for await job in scheduledJobSequence.cancelOnGracefulShutdown() {
Expand Down

0 comments on commit 84dc086

Please sign in to comment.