Async/Await
petershaw opened this issue · comments
Peter Shaw commented
Feature Request
We use Prom a lot in Vapor projects. In the contoller we have to handle the future:
func index(_ req: Request) throws -> EventLoopFuture<String> {
let promise = req.eventLoop.makePromise(of: String.self)
try MetricsSystem.prometheus().collect(into: promise)
return promise.futureResult
}
This feature request change the usage to
func index(_ req: Request) async throws -> String {
return try await MetricsSystem.prometheus().collect()
}
Motivation Behind Feature
Vapor itself will turn to fully async/await. It would be nice to habe SwiftPrometheus async/await, too.
Feature Description
Support Async/Await
Alternatives or Workarounds
We could write an extension to wrap it into a/a.
Konrad `ktoso` Malawski commented
Sounds good, feel free to send in a PR implementing this :-)