Task monad based on `Materializer`
- Dominant language
- Scala
- Stars
- 1.6k
- Forks
- 211
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 89
Description
In a pekko Java project I'm working on, I've been creating a `Task` class whose abstraction looks something like:
```java
public abstract class Task {
public static Task of(Supplier fn) {}
public static Task connect(Source source, Sink> sink) {}
/* ... */
public abstract TaskControl run(Materializer mat);
}
public class TaskControl {
public void cancel() { /* ... */ }
public CompletableFuture future() { /* ... */ }
}
```
`Task` is a description of running something, but also has a unified cancellation API (across futures and connected `RunnableGraph`s). It is inspired heavily from ZIO's API. A lot of combinators are written.
Would this be an interesting abstraction to have in Pekko itself? The fact that streams need to be materialized brings them close to a `Task` monad already, and in my experience having a unified API between running streams and futures is very valuable.
We'd of course add a nice Scala API as well (which should be trivial).
Contributor guide
Assessment
This issue has not been assessed yet.