File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44/* .xcodeproj
55DerivedData
66Package.resolved
7-
8- .swiftpm
7+ .swiftpm
8+ Tests / LinuxMain.swift
Original file line number Diff line number Diff line change @@ -133,7 +133,12 @@ public final class QueuesCommand: Command {
133133
134134 if let task = job. schedule ( context: context) {
135135 self . scheduledTasks [ job. job. name] = task
136- task. done. whenComplete { _ in
136+ task. done. whenComplete { result in
137+ switch result {
138+ case . failure( let error) :
139+ context. logger. error ( " \( job. job. name) failed: \( error) " )
140+ case . success: break
141+ }
137142 self . schedule ( job)
138143 }
139144 }
Original file line number Diff line number Diff line change @@ -149,6 +149,27 @@ final class QueueTests: XCTestCase {
149149
150150 try promise. futureResult. wait ( )
151151 }
152+
153+ func testFailingScheduledJob( ) throws {
154+ let app = Application ( . testing)
155+ defer { app. shutdown ( ) }
156+
157+ app. queues. schedule ( FailingScheduledJob ( ) ) . everySecond ( )
158+ try app. queues. startScheduledJobs ( )
159+
160+ let promise = app. eventLoopGroup. next ( ) . makePromise ( of: Void . self)
161+ app. eventLoopGroup. next ( ) . scheduleTask ( in: . seconds( 1 ) ) { ( ) -> Void in
162+ promise. succeed ( ( ) )
163+ }
164+ try promise. futureResult. wait ( )
165+ }
166+ }
167+
168+ struct Failure : Error { }
169+ struct FailingScheduledJob : ScheduledJob {
170+ func run( context: QueueContext ) -> EventLoopFuture < Void > {
171+ context. eventLoop. makeFailedFuture ( Failure ( ) )
172+ }
152173}
153174
154175struct TestingScheduledJob : ScheduledJob {
You can’t perform that action at this time.
0 commit comments