-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Netty 5] More composable Future API #8523
Comments
Is there any consideration of using Java's I actually prefer Netty's |
@Bennett-Lynch I must say I am not the biggest fan of |
My experience with |
I like to see a more functional API like https://github.com/vavr-io/vavr/blob/master/vavr/src/main/java/io/vavr/concurrent/Future.java . One thing I'm not that like |
…dapter for a Future. Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future Result: Easier inter-op with other Java8+ libaries. Related to #8523.
PTAL #9004 |
…dapter for a Future. Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future Result: Easier inter-op with other Java8+ libaries. Related to #8523.
…dapter for a Future. Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future Result: Easier inter-op with other Java8+ libaries. Related to #8523.
…dapter for a Future. Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future - Introduce FutureCompletionStage that extends CompletionStage to clarify threading semantics and guarantees. Result: Easier inter-op with other Java8+ libaries. Related to #8523.
…dapter for a Future. Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future - Introduce FutureCompletionStage that extends CompletionStage to clarify threading semantics and guarantees. Result: Easier inter-op with other Java8+ libaries. Related to #8523.
#9004) Motivation: CompletionStage is the new standard for async operation chaining in JDK8+ that is supported by various of libs. To make it easer to interopt with other libs and to allow users to make good use of lambdas and functional programming style we should allow to convert from our Future to a CompletionStage while still provide the same ordering guarantees. The reason why we expose this as toStage() and not jus have Future extend CompletionStage is for two reasons: - Keep our interface norrow - Keep semantics clear (Future.addListener(...) methods return this while all chaining methods of CompletionStage return a new instance). Modifications: - Merge implements in AbstractFuture to Future (by make these default methods) - Add Future.toStage() as a default method and a special implemention in DefaultPromise (to reduce GC). - Add Future.executor() which returns the EventExecutor that is pinned to the Future - Introduce FutureCompletionStage that extends CompletionStage to clarify threading semantics and guarantees. Result: Easier inter-op with other Java8+ libaries. Related to #8523.
…1607) Motivation: Making futures easier to compose, combine, and extend is useful to have as part of the API, since implementing this correctly and efficiently can be tricky. Modification: Add `Future.map(Function<V,R>) -> Future<R>` and `Future.flatMap(Function<V,Future<R>>) -> Future<R>` default methods to the `Future` interface. These methods return new Future instance, that will be completed when the original future completes, and the result will be processed through the given mapping function. These two methods take care to propagate cancellation and exceptions correctly: Cancellation propagates both ways between the new and original future. Failures only propagate from the original future to the returned new Future instance. Result: A few convenient methods for modifying and composing futures. This PR fixes #8523, and perhaps also #2105
|
Netty’s
Future
API has anaddListener
method which is the primary means of asynchronous notification. However this API is not composable and can lead to manually moving/aggregating/manipulating data. For example providing amap
API to transform data from one type to another, and also methods likeonSuccess
andonFailure
which allowsFuture
s to be chained and results to be modified along the way.We need to investigate case by case. That said if we provide “converter” methods to obtain a
CompletionStage
fromFuture
we may be able to use let people use this and keep ourFuture
implementation lightweight.The text was updated successfully, but these errors were encountered: