Class
EventLoopFutureQueue
Allows you to queue closures that produce an
EventLoopFuture, so each future only gets run if the previous ones complete, succeed, or fail.final class EventLoopFutureQueue
Topics
Initializers
init(eventLoop: any EventLoop)Create a newEventLoopFutureQueueon a given event loop.
Instance Properties
let eventLoop: any EventLoopThe event loop that all the futures’s completions are handled on.
Instance Methods
func append<Value>(@autoclosure () -> EventLoopFuture<Value>, runningOn: EventLoopFutureQueue.ContinueCondition) -> EventLoopFuture<Value>An overload forappend(generator:runningOn:)that takes in anEventLoopFutureas an auto closure to provide a better 1-liner API.func append(each:_:)For each element of the provided collection, invoke the given generator and queue the returned future. Return a future whose value is an array containing the result of each generated future in the same order as the original sequence. The resulting array is intended to have semantics substantially similar to those provided byEventLoop.flatten(_:on:).func append<Value>(onPrevious: EventLoopFutureQueue.ContinueCondition, generator: () -> EventLoopFuture<Value>) -> EventLoopFuture<Value>Adds anotherEventLoopFutureproducing closure to be run as soon as all previously queued future have completed, succeeded, or failed.
Enumerations
enum ContinueConditionUnder what conditions an appended closure should be run.enum ContinueErrorErrors that get propogated based on a future’s completion status and the next appended closure’s continuation condition.
See Also
EventLoopFuture
func mapEach<Result>(KeyPath<Value.Element, Result>) -> EventLoopFuture<[Result]>Gets the value of a key path for each element in the sequence that is wrapped by anEventLoopFuture.func mapEach<Result>((Value.Element) -> Result) -> EventLoopFuture<[Result]>Calls a closure on each element in the sequence that is wrapped by anEventLoopFuture.func mapEachCompact<Result>(KeyPath<Value.Element, Result?>) -> EventLoopFuture<[Result]>Gets the optional value of a key path for each element in the sequence that is wrapped by anEventLoopFuture.func mapEachCompact<Result>((Value.Element) -> Result?) -> EventLoopFuture<[Result]>Calls a closure, which returns anOptional, on each element in the sequence that is wrapped by anEventLoopFuture.func mapEachFlat<ResultSegment>(KeyPath<Value.Element, ResultSegment>) -> EventLoopFuture<[ResultSegment.Element]>Gets the collection value of a key path for each element in the sequence that is wrapped by anEventLoopFuture, combining the results into a single result collection.func mapEachFlat<ResultSegment>((Value.Element) -> ResultSegment) -> EventLoopFuture<[ResultSegment.Element]>Calls a closure which returns a collection on each element in the sequence that is wrapped by anEventLoopFuture, combining the results into a single result collection.func flatMapEach(on: any EventLoop, (Value.Element) -> EventLoopFuture<Void>) -> EventLoopFuture<Void>Calls a closure, which returns anEventLoopFuture, on each element in a sequence that is wrapped by anEventLoopFuture. No results from each future are expected.func flatMapEach<Result>(on: any EventLoop, (Value.Element) -> EventLoopFuture<Result>) -> EventLoopFuture<[Result]>Calls a closure, which returns anEventLoopFuture, on each element in a sequence that is wrapped by anEventLoopFuture.func flatMapEachCompact<Result>(on: any EventLoop, (Value.Element) -> EventLoopFuture<Result?>) -> EventLoopFuture<[Result]>Calls a closure, which returns anEventLoopFuture<Optional>, on each element in a sequence that is wrapped by anEventLoopFuture.func flatMapEachThrowing<Result>((Value.Element) throws -> Result) -> EventLoopFuture<[Result]>Calls a closure on each element in the sequence that is wrapped by anEventLoopFuture.func flatMapEachCompactThrowing<Result>((Value.Element) throws -> Result?) -> EventLoopFuture<[Result]>Calls a closure, which returns anOptional, on each element in the sequence that is wrapped by anEventLoopFuture.func sequencedFlatMapEach((Value.Element) -> EventLoopFuture<Void>) -> EventLoopFuture<Void>An overload ofsequencedFlatMapEach(_:)which returns aVoidfuture instead of[Void]when the result type of the transform closure isVoid.func sequencedFlatMapEach<Result>((Value.Element) -> EventLoopFuture<Result>) -> EventLoopFuture<[Result]>A variant form offlatMapEach(on:_:)which guarantees:func sequencedFlatMapEachCompact<Result>((Value.Element) -> EventLoopFuture<Result?>) -> EventLoopFuture<[Result]>Variant ofsequencedFlatMapEach(_:)which providescompactMap()semantics by allowing result values to benil. Such results are not included in the output array.static func whenTheySucceed<A, B>(EventLoopFuture<A>, EventLoopFuture<B>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B)>Returns a newEventLoopFuturethat succeeds only if all of the provided fs succeed. The newEventLoopFuturewill contain all of the values fulfilled by the fs.