Interface ChannelSupplier<T>
- All Superinterfaces:
io.activej.async.process.AsyncCloseable
- All Known Implementing Classes:
AbstractChannelSupplier,ChannelFileReader,ChannelSuppliers.ChannelSupplierConcat,ChannelSuppliers.ChannelSupplierEmpty,ChannelSuppliers.ChannelSupplierOfException,ChannelSuppliers.ChannelSupplierOfIterator,ChannelSuppliers.ChannelSupplierOfValue
Promise of data that should be used serially
(each consecutive get()) operation should be called only after previous
get() operation finishes.
After supplier is closed, all subsequent calls to get() will return promise,
completed exceptionally.
If any exception is caught while supplying data items, AsyncCloseable.closeEx(Exception) method
should be called. All resources should be freed and the caught exception should be
propagated to all related processes.
If get() returns Promise of null, it represents end-of-stream
and means that no additional data should be queried.
-
Field Summary
Fields inherited from interface io.activej.async.process.AsyncCloseable
STATIC -
Method Summary
Modifier and TypeMethodDescriptiondefault ChannelSupplier<T>async()Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and makes its promise complete asynchronously.default io.activej.promise.Promise<Void>bindTo(ChannelInput<T> to) Binds this ChannelSupplier to providedChannelInputdefault ChannelSupplier<T>Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and checks if its Promise's value(s) match(es) the predicate, leaving only those value(s) which pass the test.@NotNull io.activej.promise.Promise<T>get()default ChannelSupplier<T>lenient()Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier.default <V> ChannelSupplier<V>Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and when its Promise completes, applies providedfnto the result.default <V> ChannelSupplier<V>Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and applies providedfnto its Promise asynchronously.static <T> ChannelSupplier<T>of()Returns aChannelSuppliers.ChannelSupplierEmpty.static <T> ChannelSupplier<T>of(io.activej.async.function.AsyncSupplier<T> supplier) static <T> ChannelSupplier<T>of(io.activej.async.function.AsyncSupplier<T> supplier, @Nullable io.activej.async.process.AsyncCloseable closeable) WrapsAsyncSupplierin ChannelSupplier, whenget()is called,AsyncSupplier'sget()will be executed.static <T> ChannelSupplier<T>of(T value) Wraps providedvalueto aChannelSuppliers.ChannelSupplierOfValue.static <T> ChannelSupplier<T>of(T... values) static <T> ChannelSupplier<T>ofAnotherEventloop(@NotNull io.activej.eventloop.Eventloop anotherEventloop, @NotNull ChannelSupplier<T> anotherEventloopSupplier) static <T> ChannelSupplier<T>ofConsumer(Consumer<ChannelConsumer<T>> consumer, ChannelQueue<T> queue) Returns a ChannelSupplier received fromChannelQueue.static <T> ChannelSupplier<T>Returns aChannelSuppliers.ChannelSupplierOfExceptionof provided exception.static <T> ChannelSupplier<T>ofIterator(Iterator<? extends T> iterator) Wraps providedIteratorintoChannelSuppliers.ChannelSupplierOfIterator.static <T> ChannelSupplier<T>ofLazyProvider(Supplier<? extends ChannelSupplier<T>> provider) static <T> ChannelSupplier<T>static <T> ChannelSupplier<T>ofPromise(io.activej.promise.Promise<? extends ChannelSupplier<T>> promise) Wrapspromiseof ChannelSupplier in ChannelSupplier or returns the ChannelSupplier frompromiseitself.static ChannelSupplier<io.activej.bytebuf.ByteBuf>ofSocket(AsyncTcpSocket socket) WrapsAsyncTcpSocket.read()operation intoChannelSupplierstatic <T> ChannelSupplier<T>static <T> ChannelSupplier<T>ofSupplier(Supplier<io.activej.promise.Promise<T>> supplier) Wraps provided defaultSupplierto ChannelSupplier.default ChannelSupplier<T>Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and when its Promise completes successfully, the result is accepted by the providedfn.default io.activej.promise.Promise<Void>streamTo(ChannelConsumer<T> consumer) default io.activej.promise.Promise<Void>streamTo(io.activej.promise.Promise<? extends ChannelConsumer<T>> consumer) default <A,R> io.activej.promise.Promise<R> toCollector(Collector<T, A, R> collector) toList()default <R> RTransforms this ChannelSupplier with the providedfn.default ChannelSupplier<T>Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier, when itsgetis called, its values will be returned until they don't fit thepredicate.default ChannelSupplier<T>withEndOfStream(UnaryOperator<io.activej.promise.Promise<Void>> fn) default ChannelSupplier<T>withExecutor(io.activej.async.process.AsyncExecutor asyncExecutor) Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and makes its promise executed by the providedasyncExecutor.Methods inherited from interface io.activej.async.process.AsyncCloseable
close, closeEx
-
Method Details
-
get
-
of
- See Also:
-
of
static <T> ChannelSupplier<T> of(io.activej.async.function.AsyncSupplier<T> supplier, @Nullable @Nullable io.activej.async.process.AsyncCloseable closeable) WrapsAsyncSupplierin ChannelSupplier, whenget()is called,AsyncSupplier'sget()will be executed.- Type Parameters:
T- data type wrapped inAsyncSupplierand ChannelSupplier- Parameters:
supplier- anAsyncSupplierto be wrapped in ChannelSuppliercloseable- aCancellablewhich will be set for the ChannelSupplier wrapper- Returns:
- ChannelSupplier which wraps
AsyncSupplier
-
ofConsumer
static <T> ChannelSupplier<T> ofConsumer(Consumer<ChannelConsumer<T>> consumer, ChannelQueue<T> queue) Returns a ChannelSupplier received fromChannelQueue. -
ofSupplier
Wraps provided defaultSupplierto ChannelSupplier. -
of
Returns aChannelSuppliers.ChannelSupplierEmpty. -
of
Wraps providedvalueto aChannelSuppliers.ChannelSupplierOfValue.- Parameters:
value- a value to be wrapped in ChannelSupplier- Returns:
- a
ChannelSupplierOfValuewhich wraps thevalue
-
of
- See Also:
-
ofException
Returns aChannelSuppliers.ChannelSupplierOfExceptionof provided exception.- Parameters:
e- aExceptionto be wrapped in ChannelSupplier
-
ofList
- See Also:
-
ofStream
- See Also:
-
ofIterator
Wraps providedIteratorintoChannelSuppliers.ChannelSupplierOfIterator.- Parameters:
iterator- an iterator to be wrapped in ChannelSupplier- Returns:
- a ChannelSupplier which wraps elements of
type
-
ofSocket
WrapsAsyncTcpSocket.read()operation intoChannelSupplier- Returns:
ChannelSupplierof ByteBufs that are read from network
-
ofPromise
static <T> ChannelSupplier<T> ofPromise(io.activej.promise.Promise<? extends ChannelSupplier<T>> promise) Wrapspromiseof ChannelSupplier in ChannelSupplier or returns the ChannelSupplier frompromiseitself.If
promiseis completed, it will be materialized and its result (a ChannelSupplier) will be returned.Otherwise, when
get()is called, it will wait untilpromisecompletes andpromiseresult's (a ChannelSupplier)get()operation will be executed. If thepromisecompletes exceptionally, apromiseof exception will be returned.- Parameters:
promise- wraps aChannelSupplier- Returns:
- a ChannelSupplier of
promiseor a wrapper ChannelSupplier
-
ofAnotherEventloop
static <T> ChannelSupplier<T> ofAnotherEventloop(@NotNull @NotNull io.activej.eventloop.Eventloop anotherEventloop, @NotNull @NotNull ChannelSupplier<T> anotherEventloopSupplier) -
ofLazyProvider
- Parameters:
provider- a provider ofChannelSupplier- Returns:
- a
ChannelSupplierthat was wrapped in theprovider
-
transformWith
Transforms this ChannelSupplier with the providedfn.- Type Parameters:
R- returned result after transformation- Parameters:
fn-ChannelSupplierTransformerapplied to the ChannelSupplier
-
async
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and makes its promise complete asynchronously. -
withExecutor
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and makes its promise executed by the providedasyncExecutor. -
peek
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and when its Promise completes successfully, the result is accepted by the providedfn. -
map
default <V> ChannelSupplier<V> map(io.activej.common.function.FunctionEx<? super @NotNull T, ? extends V> fn) Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and when its Promise completes, applies providedfnto the result. -
mapAsync
default <V> ChannelSupplier<V> mapAsync(Function<? super @NotNull T, io.activej.promise.Promise<V>> fn) Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and applies providedfnto its Promise asynchronously. -
filter
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier and checks if its Promise's value(s) match(es) the predicate, leaving only those value(s) which pass the test. -
until
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier, when itsgetis called, its values will be returned until they don't fit thepredicate. If one of the results passed thepredicate test, consequentgetoperations will returnnull. -
lenient
Creates and returns a newAbstractChannelSupplierbased on current ChannelSupplier. Even if its Promise completes with an exception,get()method will return a successfully completed Promise (in case of exception, withnullresult value). -
streamTo
-
streamTo
default io.activej.promise.Promise<Void> streamTo(io.activej.promise.Promise<? extends ChannelConsumer<T>> consumer) -
bindTo
Binds this ChannelSupplier to providedChannelInput -
toCollector
-
toList
- See Also:
-
withEndOfStream
-