diff --git a/Package.swift b/Package.swift index 8f28cbd..54f2d9d 100644 --- a/Package.swift +++ b/Package.swift @@ -8,8 +8,8 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"), - .package(url: "https://github.com/christophhagen/Clairvoyant", from: "0.9.0"), - .package(url: "https://github.com/christophhagen/ClairvoyantVapor", from: "0.2.0"), + .package(url: "https://github.com/christophhagen/Clairvoyant", from: "0.13.0"), + .package(url: "https://github.com/christophhagen/ClairvoyantVapor", from: "0.5.0"), .package(url: "https://github.com/christophhagen/ClairvoyantBinaryCodable", from: "0.3.1"), ], targets: [ diff --git a/Sources/App/EventLoopScheduler.swift b/Sources/App/EventLoopScheduler.swift index 8e10a5b..69ade3f 100644 --- a/Sources/App/EventLoopScheduler.swift +++ b/Sources/App/EventLoopScheduler.swift @@ -1,34 +1,10 @@ import Foundation import Vapor -import NIOCore import Clairvoyant -final class EventLoopScheduler { +extension MultiThreadedEventLoopGroup: AsyncScheduler { - private let backgroundGroup: EventLoopGroup - - init() { - backgroundGroup = MultiThreadedEventLoopGroup(numberOfThreads: 2) - } - - func next() -> EventLoop { - backgroundGroup.next() - } - - func provider() -> NIOEventLoopGroupProvider { - return .shared(backgroundGroup) - } - - func shutdown() { - backgroundGroup.shutdownGracefully { _ in - - } - } -} - -extension EventLoopScheduler: AsyncScheduler { - - func schedule(asyncJob: @escaping @Sendable () async throws -> Void) { - _ = backgroundGroup.any().makeFutureWithTask(asyncJob) + public func schedule(asyncJob: @escaping @Sendable () async throws -> Void) { + _ = any().makeFutureWithTask(asyncJob) } } diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index a65fdcf..a4e8afc 100755 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -7,7 +7,7 @@ var deviceManager: DeviceManager! private var provider: VaporMetricProvider! -private var asyncScheduler = EventLoopScheduler() +private var asyncScheduler: AsyncScheduler = MultiThreadedEventLoopGroup(numberOfThreads: 2) enum ServerError: Error { case invalidAuthenticationFileContent