AsyncKit
Provides a set of utilities for working with EventLoopFutures and other pre-Concurrency support APIs.
import AsyncKit
Module information
- Declarations
- 165
- Symbols
- 187
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.
Legacy connection pools
class EventLoopConnectionPool<Source>
Holds a collection of active connections that can be requested and later released back into the pool.
class EventLoopGroupConnectionPool<Source>
Holds a collection of connection pools for each
EventLoop
on anEventLoopGroup
.protocol ConnectionPoolSource
Source of new connections for
ConnectionPool
.protocol ConnectionPoolItem
Item managed by a connection pool.
enum ConnectionPoolError
Errors thrown by
ConnectionPool
.enum ConnectionPoolTimeoutError
Optionals
func strictMap<A, Res>(A?, (A) throws -> Res
) rethrows -> Res? Given one or more optionals as inputs, checks whether each input is
nil
. If any input isnil
,nil
is immediately returned as an overall results. If all of the inputs have values, thetransform
callback 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 new
EventLoopFuture
that succeeds only when all the provided futures succeed. The newEventLoopFuture
contains an array of results, maintaining same ordering as the futures.func flatten([EventLoopFuture<Void>]
) -> EventLoopFuture<Void> Returns a new
EventLoopFuture
that succeeds only when all the provided futures succeed, ignoring the resolved values.func future(
) -> EventLoopFuture<Void> Creates a new, succeeded
EventLoopFuture
from the worker’s event loop with aVoid
value.func future<T>(error: Error
) -> EventLoopFuture<T> Creates a new, failed
EventLoopFuture
from the worker’s event loop.func future<T>(T
) -> EventLoopFuture<T> Creates a new, succeeded
EventLoopFuture
from the worker’s event loop.func future<T>(result: Result<T, Error>
) -> EventLoopFuture<T> Creates a new
Future
from the worker’s event loop, succeeded or failed based on the inputResult
.func tryFuture<T>(@escaping () throws -> T
) -> EventLoopFuture<T> An alternate name for this would be
future(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 EventLoopFutureQueue
Allows you to queue closures that produce an
EventLoopFuture
, 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 an
EventLoopFuture
.func mapEach<Result>(@escaping (_ element: Value.Element) -> Result
) -> EventLoopFuture<[Result]> Calls a closure on each element in the sequence that is wrapped by an
EventLoopFuture
.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 an
EventLoopFuture
.func mapEachCompact<Result>(@escaping (_ element: Value.Element) -> Result?
) -> EventLoopFuture<[Result]> Calls a closure, which returns an
Optional
, 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 an
EventLoopFuture
, combining the results into a single result collection.func mapEachFlat<ResultSegment>(@escaping (_ element: Value.Element) -> ResultSegment
) -> EventLoopFuture<[ResultSegment.Element]> Calls a closure which returns a collection on each element in the sequence that is wrapped by an
EventLoopFuture
, combining the results into a single result collection.func flatMapEach(on: EventLoop, @escaping (_ element: Value.Element) -> EventLoopFuture<Void>
) -> EventLoopFuture<Void> Calls a closure, which returns an
EventLoopFuture
, on each element in a sequence that is wrapped by anEventLoopFuture
. No results from each future are expected.func flatMapEach<Result>(on: EventLoop, @escaping (_ element: Value.Element) -> EventLoopFuture<Result>
) -> EventLoopFuture<[Result]> Calls a closure, which returns an
EventLoopFuture
, on each element in a sequence that is wrapped by anEventLoopFuture
.func flatMapEachCompact<Result>(on: EventLoop, @escaping (_ element: Value.Element) -> EventLoopFuture<Result?>
) -> EventLoopFuture<[Result]> Calls a closure, which returns an
EventLoopFuture<Optional>
, on each element in a sequence that is wrapped by anEventLoopFuture
.func flatMapEachThrowing<Result>(@escaping (_ element: Value.Element) throws -> Result
) -> EventLoopFuture<[Result]> Calls a closure on each element in the sequence that is wrapped by an
EventLoopFuture
.func flatMapEachCompactThrowing<Result>(@escaping (_ element: Value.Element) throws -> Result?
) -> EventLoopFuture<[Result]> Calls a closure, which returns an
Optional
, on each element in the sequence that is wrapped by anEventLoopFuture
.func sequencedFlatMapEach(@escaping (_ element: Value.Element) -> EventLoopFuture<Void>
) -> EventLoopFuture<Void> An overload of
sequencedFlatMapEach(_:)
which returns aVoid
future instead of[Void]
when the result type of the transform closure isVoid
.func sequencedFlatMapEach<Result>(@escaping (_ element: Value.Element) -> EventLoopFuture<Result>
) -> EventLoopFuture<[Result]> A variant form of
flatMapEach(on:_:)
which guarantees:func sequencedFlatMapEachCompact<Result>(@escaping (_ element: Value.Element) -> EventLoopFuture<Result?>
) -> EventLoopFuture<[Result]> Variant of
sequencedFlatMapEach(_:)
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 new
EventLoopFuture
that succeeds only if all of the provided fs succeed. The newEventLoopFuture
will 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`(@escaping ((Value) -> Bool), else: @autoclosure @escaping () -> 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, @escaping (Result<Value, Error>) -> EventLoopFuture<NewValue>
) -> EventLoopFuture<NewValue> When the current
EventLoopFuture
receives 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 @escaping () -> E
) -> EventLoopFuture<Value> Checks that the future’s value (if any) returns
false
for.isEmpty
. If the check fails, the provided error is thrown.func nonemptyMap<NewValue>(@escaping (Value) -> NewValue
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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 anArray
or aRangeReplaceableCollection
.func nonemptyMap<NewValue>(or: @autoclosure @escaping () -> NewValue, @escaping (Value) -> NewValue
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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>(@escaping (Value) throws -> NewValue
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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 anArray
or aRangeReplaceableCollection
.func nonemptyFlatMapThrowing<NewValue>(or: @autoclosure @escaping () -> NewValue, @escaping (Value) throws -> NewValue
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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>(@escaping (Value) -> EventLoopFuture<NewValue>
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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 anArray
or aRangeReplaceableCollection
.func nonemptyFlatMap<NewValue>(or: @autoclosure @escaping () -> NewValue, @escaping (Value) -> EventLoopFuture<NewValue>
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.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 @escaping () -> EventLoopFuture<NewValue>, @escaping (Value) -> EventLoopFuture<NewValue>
) -> EventLoopFuture<NewValue> Checks that the future’s value (if any) returns
false
for.isEmpty
. If the check fails, the provided alternate future is returned. Otherwise, the provided normalflatMap()
callback is invoked.func optionalMap<Wrapped, Result>(@escaping (_ unwrapped: Wrapped) -> Result?
) -> EventLoopFuture<Result?> Calls a closure on an optional value that is wrapped in an
EventLoopFuture
if it exists.func optionalFlatMap<Wrapped, Result>(@escaping (_ unwrapped: Wrapped) -> EventLoopFuture<Result>
) -> EventLoopFuture<Result?> Calls a closure on an optional value in an
EventLoopFuture
if it exists.func optionalFlatMap<Wrapped, Result>(@escaping (_ unwrapped: Wrapped) -> EventLoopFuture<Result?>
) -> EventLoopFuture<Result?> Calls a closure that returns an optional future on an optional value in an
EventLoopFuture
if it exists.func optionalFlatMapThrowing<Wrapped, Result>(@escaping (_ unwrapped: Wrapped) throws -> Result?
) -> EventLoopFuture<Result?> Calls a throwing closure on an optional value in an
EventLoopFuture
if 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 @escaping () -> 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, @escaping (Value) throws -> EventLoopFuture<NewValue>
) -> EventLoopFuture<NewValue>
EventLoopFuture operators
static func + (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Adds two futures and produces their sum
static func + <T>(lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Adds two futures and produces their sum
static func += (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Adds two futures and stores the result in the left-hand-side variable
static func += <T>(lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Adds two futures and stores the result in the left-hand-side variable
static func * (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Multiplies two futures and produces their product
static func *= (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Multiplies two futures and stores the result in the left-hand-side variable
static func % (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Returns the remainder of dividing the first future by the second
static func %= (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Divides the first future by the second and stores the remainder in the left-hand-side variable
static func < (lhs: EventLoopFuture, rhs: EventLoopFuture<some BinaryInteger>
) -> EventLoopFuture<Bool> Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument
static func <= (lhs: EventLoopFuture, rhs: 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 argument
static func > (lhs: EventLoopFuture, rhs: EventLoopFuture<some BinaryInteger>
) -> EventLoopFuture<Bool> Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument
static func >= (lhs: EventLoopFuture, rhs: 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 argument
static func << (lhs: EventLoopFuture, rhs: EventLoopFuture<some BinaryInteger>
) -> EventLoopFuture Returns the result of shifting a future’s binary representation the specified number of digits to the left
static func <<= (lhs: inout EventLoopFuture, rhs: 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 variable
static func >> (lhs: EventLoopFuture, rhs: EventLoopFuture<some BinaryInteger>
) -> EventLoopFuture Returns the result of shifting a future’s binary representation the specified number of digits to the right
static func >>= (lhs: inout EventLoopFuture, rhs: 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 variable
static func & (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Returns the result of performing a bitwise AND operation on the two given futures
static func &= (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Stores the result of performing a bitwise AND operation on the two given futures in the left-hand-side variable
static func | (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Returns the result of performing a bitwise OR operation on the two given futures
static func |= (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Stores the result of performing a bitwise OR operation on the two given futures in the left-hand-side variable
static func ^ (lhs: EventLoopFuture, rhs: EventLoopFuture
) -> EventLoopFuture Returns the result of performing a bitwise XOR operation on the two given futures
static func ^= (lhs: inout EventLoopFuture, rhs: EventLoopFuture
) Stores the result of performing a bitwise XOR operation on the two given futures in the left-hand-side variable
static func ~ (x: EventLoopFuture
) -> EventLoopFuture Returns the result of performing a bitwise NOT operation on the given future