Skip to content

Commit

Permalink
Attempt at implementing shutdown() to avoid hanging when application …
Browse files Browse the repository at this point in the history
…exits
  • Loading branch information
m-barthelemy committed Apr 26, 2020
1 parent 3bb54f6 commit ddce52e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Sources/QueuesFluentDriver/FluentQueuesDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public struct FluentQueuesDriver {
let databaseId: DatabaseID?
let dbType: QueuesFluentDbType
let useSoftDeletes: Bool
let eventLoopGroup: EventLoopGroup

init(on databaseId: DatabaseID? = nil, useSoftDeletes: Bool) {
init(on databaseId: DatabaseID? = nil, useSoftDeletes: Bool, on: EventLoopGroup) {
self.databaseId = databaseId
self.useSoftDeletes = useSoftDeletes
self.dbType = .postgresql
self.eventLoopGroup = on
}
}

Expand All @@ -35,5 +37,8 @@ extension FluentQueuesDriver: QueuesDriver {
)
}

public func shutdown() {}
public func shutdown() {
// What are we supposed to do here?
try? self.eventLoopGroup.syncShutdownGracefully()
}
}
2 changes: 1 addition & 1 deletion Sources/QueuesFluentDriver/Queues.Provider+fluent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension Application.Queues.Provider {
public static func fluent(_ databaseId: DatabaseID? = nil, useSoftDeletes: Bool = true) -> Self {
.init {
$0.queues.use(custom:
FluentQueuesDriver(on: databaseId, useSoftDeletes: useSoftDeletes)
FluentQueuesDriver(on: databaseId, useSoftDeletes: useSoftDeletes, on: $0.eventLoopGroup)
)
}
}
Expand Down

0 comments on commit ddce52e

Please sign in to comment.