Skip to content

Commit

Permalink
add scenario 11
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesward committed Dec 23, 2024
1 parent b4c7721 commit 3068af6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug
| Source | Scenario Coverage | Author(s) | Notes |
|----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|-----------------------------|
| [Scala 3 + ZIO](scala-zio) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-zio.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Scala 3 + Ox](scala-ox) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-ox.yaml/badge.svg) | [Adam Warski](https://github.com/adamw) | |
| [Scala 3 + Kyo](scala-kyo) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-kyo.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Scala 3 + Ox](scala-ox) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-ox.yaml/badge.svg) | [Adam Warski](https://github.com/adamw) | |
| [Scala 3 + Kyo](scala-kyo) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-kyo.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Scala 3 + Gears](scala-gears) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-gears.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | |
| [Scala 3 + Akka Streams](scala-akkastreams) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-akkastreams.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | |
| [Kotlin + Coroutines](kotlin-coroutines) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-coroutines.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | |
| [Kotlin + Flow](kotlin-flow) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-flow.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | |
| [Kotlin + Splitties](kotlin-splitties) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-splitties.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Kotlin + Arrow](kotlin-arrow) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-arrow.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Java + Loom](java-loom) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/java-loom.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Java + Loom](java-loom) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/java-loom.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Java + Jox](java-jox) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/java-jox.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | |
| [Rust + Tokio](rust-tokio) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/rust-tokio.yaml/badge.svg) | [James Ward](https://github.com/jamesward) and Rust Developer Retreat Participants | |
| [C#](dotnet) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/dotnet.yaml/badge.svg) | [Jason De Lorme](https://github.com/delormej) | Scenario 10: CPU Not Pegged |
Expand Down
22 changes: 20 additions & 2 deletions java-loom/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,27 @@ class Recursive<I> {
}
}

public String scenario11() throws ExecutionException, InterruptedException {
var req = HttpRequest.newBuilder(url.resolve("/11")).build();

try (var outerScope = new StructuredTaskScope.ShutdownOnSuccess<HttpResponse<String>>()) {
outerScope.fork(() -> client.send(req, HttpResponse.BodyHandlers.ofString()));
outerScope.fork(() -> {
try (var innerScope = new StructuredTaskScope.ShutdownOnSuccess<HttpResponse<String>>()) {
innerScope.fork(() -> client.send(req, HttpResponse.BodyHandlers.ofString()));
innerScope.fork(() -> client.send(req, HttpResponse.BodyHandlers.ofString()));
innerScope.join();
return innerScope.result();
}
});
outerScope.join();
return outerScope.result().body();
}
}

List<String> results() throws ExecutionException, InterruptedException {
return List.of(scenario1(), scenario2(), scenario3(), scenario4(), scenario5(), scenario6(), scenario7(), scenario8(), scenario9(), scenario10());
//return List.of(scenario10());
return List.of(scenario1(), scenario2(), scenario3(), scenario4(), scenario5(), scenario6(), scenario7(), scenario8(), scenario9(), scenario10(), scenario11());
// return List.of(scenario11());
}
}

Expand Down
9 changes: 7 additions & 2 deletions scala-kyo/src/main/scala/EasyRacerClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,15 @@ object EasyRacerClient extends KyoApp:
val (_, result) = await(Async.parallel(blocker(id), reporter(id)))
result

def scenario11(scenarioUrl: Int => Uri) =
val url = scenarioUrl(11)
val req = Requests(_.get(url))
Async.race(Async.race(req, req), req)

def scenarioUrl(scenario: Int) = uri"http://localhost:8080/$scenario"

def scenarios = Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10)
// def scenarios = Seq(scenario9)
def scenarios = Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10, scenario11)
// def scenarios = Seq(scenario11)

run:
Kyo.collect(scenarios.map(s => s(scenarioUrl)))
9 changes: 7 additions & 2 deletions scala-ox/src/main/scala/EasyRacerClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ object EasyRacerClient extends OxApp.Simple:
val (_, result) = par(blocker, reporter)
result

def scenario11(scenarioUrl: Int => Uri): String =
val url = scenarioUrl(11)
def req = scenarioRequest(url).send(backend).body
raceSuccess(raceSuccess(req, req), req)


def run(using Ox): Unit =
def scenarioUrl(scenario: Int) = uri"http://localhost:8080/$scenario"
def scenarios = Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10)
// def scenarios: Seq[(Int => Uri) => String] = Seq(scenario8)
def scenarios = Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10, scenario11)
// def scenarios: Seq[(Int => Uri) => String] = Seq(scenario11)
scenarios.foreach: s =>
println(s(scenarioUrl))

0 comments on commit 3068af6

Please sign in to comment.