Created
June 23, 2025 17:04
-
-
Save zainab-ali/fb78a2b8173c9e1105a30a968c2209e9 to your computer and use it in GitHub Desktop.
aquascape: metered & parEvalMapUnorderedUnbounded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala "3.7.0" | |
//> using dep "com.github.zainab-ali::aquascape::0.4.0" | |
import fs2.* | |
import cats.effect.* | |
import aquascape.* | |
import aquascape.drawing.* | |
import scala.concurrent.duration.* | |
object MeteredParEvalMapUnbounded extends AquascapeApp { | |
override def config: Config = super.config.scale(4) | |
def name: String = "aquascape" | |
def stream(using Scape[IO]): IO[Unit] = { | |
Stream('a', 'b', 'c', 'd') | |
.stage("input", "upstream") | |
.metered(1.second) | |
.stage("metered(1s)", "upstream") | |
.fork("root", "upstream") | |
.parEvalMapUnorderedUnbounded(c => IO.sleep(3.seconds).as(c)) | |
.stage("parEvalMapUnorderedUnbounded(sleep(3s))") | |
.compile | |
.drain | |
.compileStage("output") | |
.void | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with
scala-cli https://gist.github.com/zainab-ali/fb78a2b8173c9e1105a30a968c2209e9
and openaquscape.png
:Learn how to read he aquascapes.