Package
AsyncKit
Provides a set of utilities for working with EventLoopFutures and other pre-Concurrency support APIs.
Overview
AsyncKit is a legacy package; its use is not recommended in new projects.
AsyncKit provides a number of extensions to both Swift’s Concurrency primitives and NIO’s futures to make working with them easier. The long-term goal is to migrate away from this package as Swift Concurrency adds support for working in an asynchronous environment easy.
See references below for usage details.
Topics
Legacy connection pools
class EventLoopConnectionPoolHolds a collection of active connections that can be requested and later released back into the pool.class EventLoopGroupConnectionPoolHolds a collection of connection pools for eachEventLoopon anEventLoopGroup.protocol ConnectionPoolSourceSource of new connections forEventLoopGroupConnectionPool.protocol ConnectionPoolItemItem managed by a connection pool.enum ConnectionPoolErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding state.enum ConnectionPoolTimeoutErrorErrors thrown byEventLoopGroupConnectionPoolandEventLoopConnectionPoolregarding timeouts.
Optionals
func strictMap<A, Res>(A?, (A) throws -> Res) rethrows -> Res?Given one or more optionals as inputs, checks whether each input isnil. If any input isnil,nilis immediately returned as an overall results. If all of the inputs have values, thetransformcallback is invoked with all of the unwrapped values as parameters.func strictMap<A, B, Res>(A?, B?, (A, B) throws -> Res) rethrows -> Res?strictMap(_:_:)over 2 optionals.func strictMap<A, B, C, Res>(A?, B?, C?, (A, B, C) throws -> Res) rethrows -> Res?strictMap(_:_:)over 3 optionals.func strictMap<A, B, C, D, Res>(A?, B?, C?, D?, (A, B, C, D) throws -> Res) rethrows -> Res?strictMap(_:_:)over 4 optionals.func strictMap<A, B, C, D, E, Res>(A?, B?, C?, D?, E?, (A, B, C, D, E) throws -> Res) rethrows -> Res?strictMap(_:_:)over 5 optionals.func strictMap<A, B, C, D, E, F, Res>(A?, B?, C?, D?, E?, F?, (A, B, C, D, E, F) throws -> Res) rethrows -> Res?strictMap(_:_:)over 6 optionals.func strictMap<A, B, C, D, E, F, G, Res>(A?, B?, C?, D?, E?, F?, G?, (A, B, C, D, E, F, G) throws -> Res) rethrows -> Res?strictMap(_:_:)over 7 optionals.func strictMap<A, B, C, D, E, F, G, H, Res>(A?, B?, C?, D?, E?, F?, G?, H?, (A, B, C, D, E, F, G, H) throws -> Res) rethrows -> Res?strictMap(_:_:)over 8 optionals.func strictMap<A, B, C, D, E, F, G, H, I, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, (A, B, C, D, E, F, G, H, I) throws -> Res) rethrows -> Res?strictMap(_:_:)over 9 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, (A, B, C, D, E, F, G, H, I, J) throws -> Res) rethrows -> Res?strictMap(_:_:)over 10 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, (A, B, C, D, E, F, G, H, I, J, K) throws -> Res) rethrows -> Res?strictMap(_:_:)over 11 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, (A, B, C, D, E, F, G, H, I, J, K, L) throws -> Res) rethrows -> Res?strictMap(_:_:)over 12 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, (A, B, C, D, E, F, G, H, I, J, K, L, M) throws -> Res) rethrows -> Res?strictMap(_:_:)over 13 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N) throws -> Res) rethrows -> Res?strictMap(_:_:)over 14 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) throws -> Res) rethrows -> Res?strictMap(_:_:)over 15 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, P?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) throws -> Res) rethrows -> Res?strictMap(_:_:)over 16 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, P?, Q?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q) throws -> Res) rethrows -> Res?strictMap(_:_:)over 17 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, P?, Q?, R?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) throws -> Res) rethrows -> Res?strictMap(_:_:)over 18 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, P?, Q?, R?, S?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) throws -> Res) rethrows -> Res?strictMap(_:_:)over 19 optionals.func strictMap<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, Res>(A?, B?, C?, D?, E?, F?, G?, H?, I?, J?, K?, L?, M?, N?, O?, P?, Q?, R?, S?, T?, (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) throws -> Res) rethrows -> Res?strictMap(_:_:)over 20 optionals.
EventLoop and EventLoopGroup
func flatten<T>([EventLoopFuture<T>]) -> EventLoopFuture<[T]>Returns a newEventLoopFuturethat succeeds only when all the provided futures succeed. The newEventLoopFuturecontains an array of results, maintaining same ordering as the futures.func flatten([EventLoopFuture<Void>]) -> EventLoopFuture<Void>Returns a newEventLoopFuturethat succeeds only when all the provided futures succeed, ignoring the resolved values.func future() -> EventLoopFuture<Void>Creates a new, succeededEventLoopFuturefrom the worker’s event loop with aVoidvalue.func future<T>(error: any Error) -> EventLoopFuture<T>Creates a new, failedEventLoopFuturefrom the worker’s event loop.func future<T>(T) -> EventLoopFuture<T>Creates a new, succeededEventLoopFuturefrom the worker’s event loop.func future<T>(result: Result<T, any Error>) -> EventLoopFuture<T>Creates a newFuturefrom the worker’s event loop, succeeded or failed based on the inputResult.func tryFuture<T>(() throws -> T) -> EventLoopFuture<T>An alternate name for this would befuture(catching:), but with that name, trailing closure syntax just looks likeel.future { ... }, which does not indicate to readers of the code that it is the error-capturing version. Since such an indication is highly desirable, a slightly less idiomatic name is used instead.
EventLoopFuture
class EventLoopFutureQueueAllows you to queue closures that produce anEventLoopFuture, so each future only gets run if the previous ones complete, succeed, or fail.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.static func whenTheySucceed<A, B, C>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C)>whenTheySucceed(_:_:file:line:)of order 3.static func whenTheySucceed<A, B, C, D>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D)>whenTheySucceed(_:_:file:line:)of order 4.static func whenTheySucceed<A, B, C, D, E>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E)>whenTheySucceed(_:_:file:line:)of order 5.static func whenTheySucceed<A, B, C, D, E, F>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F)>whenTheySucceed(_:_:file:line:)of order 6.static func whenTheySucceed<A, B, C, D, E, F, G>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G)>whenTheySucceed(_:_:file:line:)of order 7.static func whenTheySucceed<A, B, C, D, E, F, G, H>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H)>whenTheySucceed(_:_:file:line:)of order 8.static func whenTheySucceed<A, B, C, D, E, F, G, H, I>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I)>whenTheySucceed(_:_:file:line:)of order 9.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J)>whenTheySucceed(_:_:file:line:)of order 10.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K)>whenTheySucceed(_:_:file:line:)of order 11.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L)>whenTheySucceed(_:_:file:line:)of order 12.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M)>whenTheySucceed(_:_:file:line:)of order 13.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)>whenTheySucceed(_:_:file:line:)of order 14.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)>whenTheySucceed(_:_:file:line:)of order 15.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, EventLoopFuture<P>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)>whenTheySucceed(_:_:file:line:)of order 16.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, EventLoopFuture<P>, EventLoopFuture<Q>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)>whenTheySucceed(_:_:file:line:)of order 17.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, EventLoopFuture<P>, EventLoopFuture<Q>, EventLoopFuture<R>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)>whenTheySucceed(_:_:file:line:)of order 18.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, EventLoopFuture<P>, EventLoopFuture<Q>, EventLoopFuture<R>, EventLoopFuture<S>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)>whenTheySucceed(_:_:file:line:)of order 19.static func whenTheySucceed<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(EventLoopFuture<A>, EventLoopFuture<B>, EventLoopFuture<C>, EventLoopFuture<D>, EventLoopFuture<E>, EventLoopFuture<F>, EventLoopFuture<G>, EventLoopFuture<H>, EventLoopFuture<I>, EventLoopFuture<J>, EventLoopFuture<K>, EventLoopFuture<L>, EventLoopFuture<M>, EventLoopFuture<N>, EventLoopFuture<O>, EventLoopFuture<P>, EventLoopFuture<Q>, EventLoopFuture<R>, EventLoopFuture<S>, EventLoopFuture<T>, file: StaticString, line: UInt) -> EventLoopFuture<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)>whenTheySucceed(_:_:file:line:)of order 20.func `guard`((Value) -> Bool, else: @autoclosure () -> any Error) -> EventLoopFuture<Value>Guards that the future’s value satisfies the callback’s condition or fails with the given error.func flatMapAlways<NewValue>(file: StaticString, line: UInt, (Result<Value, any Error>) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue>When the currentEventLoopFuturereceives any result, run the provided callback, which will provide a newEventLoopFuture. Essentially combines the behaviors of.always(_:)and.flatMap(file:line:_:).func nonempty<E>(orError: @autoclosure () -> E) -> EventLoopFuture<Value>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, the provided error is thrown.func nonemptyMap<NewValue>((Value) -> NewValue) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with an empty array as its value is returned. Otherwise, the provided normalmap()callback is invoked. The callback’s return type must be anArrayor aRangeReplaceableCollection.func nonemptyMap<NewValue>(or: @autoclosure () -> NewValue, (Value) -> NewValue) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with the provided alternate value is returned. Otherwise, the provided normalmap()callback is invoked.func nonemptyFlatMapThrowing<NewValue>((Value) throws -> NewValue) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with an empty array as its value is returned. Otherwise, the provided normalflatMapThrowing()callback is invoked. The callback’s return type must be anArrayor aRangeReplaceableCollection.func nonemptyFlatMapThrowing<NewValue>(or: @autoclosure () -> NewValue, (Value) throws -> NewValue) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with the provided alternate value is returned. Otherwise, the provided normalflatMapThrowing()callback is invoked.func nonemptyFlatMap<NewValue>((Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with an empty array as its value is returned. Otherwise, the provided normalflatMap()callback is invoked. The callback’s returned future must have a value type that is anArrayor aRangeReplaceableCollection.func nonemptyFlatMap<NewValue>(or: @autoclosure () -> NewValue, (Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, a new future with the provided alternate value is returned. Otherwise, the provided normalflatMap()callback is invoked.func nonemptyFlatMap<NewValue>(orFlat: @autoclosure () -> EventLoopFuture<NewValue>, (Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue>Checks that the future’s value (if any) returnsfalsefor.isEmpty. If the check fails, the provided alternate future is returned. Otherwise, the provided normalflatMap()callback is invoked.func optionalMap<Wrapped, Result>((Wrapped) -> Result?) -> EventLoopFuture<Result?>Calls a closure on an optional value that is wrapped in anEventLoopFutureif it exists.func optionalFlatMap<Wrapped, Result>((Wrapped) -> EventLoopFuture<Result>) -> EventLoopFuture<Result?>Calls a closure on an optional value in anEventLoopFutureif it exists.func optionalFlatMap<Wrapped, Result>((Wrapped) -> EventLoopFuture<Result?>) -> EventLoopFuture<Result?>Calls a closure that returns an optional future on an optional value in anEventLoopFutureif it exists.func optionalFlatMapThrowing<Wrapped, Result>((Wrapped) throws -> Result?) -> EventLoopFuture<Result?>Calls a throwing closure on an optional value in anEventLoopFutureif it exists.func transform<T>(to: EventLoopFuture<T>) -> EventLoopFuture<T>Maps the current future to contain the new type. Errors are carried over, successful (expected) results are transformed into the given instance.func transform<T>(to: @autoclosure () -> T) -> EventLoopFuture<T>Maps the current future to contain the new type. Errors are carried over, successful (expected) results are transformed into the given instance.func tryFlatMap<NewValue>(file: StaticString, line: UInt, (Value) throws -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue>
EventLoopFuture operators
static func + (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Adds two futures and produces their sumstatic func + <T>(EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Adds two futures and produces their sumstatic func += (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Adds two futures and stores the result in the left-hand-side variablestatic func += <T>(inout EventLoopFuture<Value>, EventLoopFuture<Value>)Adds two futures and stores the result in the left-hand-side variablestatic func * (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Multiplies two futures and produces their productstatic func *= (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Multiplies two futures and stores the result in the left-hand-side variablestatic func % (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Returns the remainder of dividing the first future by the secondstatic func %= (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Divides the first future by the second and stores the remainder in the left-hand-side variablestatic func < (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Bool>Returns a Boolean value indicating whether the value of the first argument is less than that of the second argumentstatic func <= (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Bool>Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argumentstatic func > (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Bool>Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argumentstatic func >= (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Bool>Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argumentstatic func << (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Value>Returns the result of shifting a future’s binary representation the specified number of digits to the leftstatic func <<= (inout EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>)Stores the result of shifting a future’s binary representation the specified number of digits to the left in the left-hand-side variablestatic func >> (EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>) -> EventLoopFuture<Value>Returns the result of shifting a future’s binary representation the specified number of digits to the rightstatic func >>= (inout EventLoopFuture<Value>, EventLoopFuture<some BinaryInteger>)Stores the result of shifting a future’s binary representation the specified number of digits to the right in the left-hand-side variablestatic func & (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Returns the result of performing a bitwise AND operation on the two given futuresstatic func &= (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Stores the result of performing a bitwise AND operation on the two given futures in the left-hand-side variablestatic func | (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Returns the result of performing a bitwise OR operation on the two given futuresstatic func |= (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Stores the result of performing a bitwise OR operation on the two given futures in the left-hand-side variablestatic func ^ (EventLoopFuture<Value>, EventLoopFuture<Value>) -> EventLoopFuture<Value>Returns the result of performing a bitwise XOR operation on the two given futuresstatic func ^= (inout EventLoopFuture<Value>, EventLoopFuture<Value>)Stores the result of performing a bitwise XOR operation on the two given futures in the left-hand-side variablestatic func ~ (EventLoopFuture<Value>) -> EventLoopFuture<Value>Returns the result of performing a bitwise NOT operation on the given future