From f26df30fab1645e62eaac643ff8b2f77f84543e9 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 12:55:01 -0800 Subject: [PATCH 01/27] Implemented swift-combine scenario 11. --- swift-combine/Sources/EasyRacer/EasyRacer.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/swift-combine/Sources/EasyRacer/EasyRacer.swift b/swift-combine/Sources/EasyRacer/EasyRacer.swift index e274c1b1..7496a294 100644 --- a/swift-combine/Sources/EasyRacer/EasyRacer.swift +++ b/swift-combine/Sources/EasyRacer/EasyRacer.swift @@ -250,6 +250,17 @@ public struct EasyRacer { .eraseToAnyPublisher() } + func scenario11() -> AnyPublisher { + let url: URL = baseURL.appending(path: "11") + let publisher = urlSession + .bodyTextTaskPublisher(for: url) + .map { $0 }.replaceError(with: nil) + + return publisher.merge(with: publisher.merge(with: publisher)) + .compactMap { $0 }.first() + .eraseToAnyPublisher() + } + public func scenarios() -> AnyPublisher<[String?], Never> { let scenarios = [ (1, scenario1()), @@ -261,6 +272,7 @@ public struct EasyRacer { (8, scenario8()), (9, scenario9()), (10, scenario10()), + (11, scenario11()), (3, scenario3()), // This has to come last, as it frequently causes other scenarios to fail ] return scenarios.publisher From edcfdaad56721185c402c59660eb43344d4ecbac Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 13:02:48 -0800 Subject: [PATCH 02/27] Increment test scenarios count. --- swift-combine/Tests/EasyRacerTests/EasyRacerTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift-combine/Tests/EasyRacerTests/EasyRacerTests.swift b/swift-combine/Tests/EasyRacerTests/EasyRacerTests.swift index d097e4a7..df942b22 100644 --- a/swift-combine/Tests/EasyRacerTests/EasyRacerTests.swift +++ b/swift-combine/Tests/EasyRacerTests/EasyRacerTests.swift @@ -48,7 +48,7 @@ final class EasyRacerTests: XCTestCase { .sink( receiveCompletion: { _ in completed.signal() }, receiveValue: { results in - XCTAssertEqual(results.count, 10, "Number of Scenarios") + XCTAssertEqual(results.count, 11, "Number of Scenarios") for (idx, result) in results.enumerated() { XCTAssertEqual(result, "right", "Scenario \(idx + 1)") } From 6d424ffb820923d844c912bf627f97c442865d62 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 14:55:09 -0800 Subject: [PATCH 03/27] Re-ordered swift-combine scenario 11 calls --- swift-combine/Sources/EasyRacer/EasyRacer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift-combine/Sources/EasyRacer/EasyRacer.swift b/swift-combine/Sources/EasyRacer/EasyRacer.swift index 7496a294..22db30ac 100644 --- a/swift-combine/Sources/EasyRacer/EasyRacer.swift +++ b/swift-combine/Sources/EasyRacer/EasyRacer.swift @@ -256,7 +256,7 @@ public struct EasyRacer { .bodyTextTaskPublisher(for: url) .map { $0 }.replaceError(with: nil) - return publisher.merge(with: publisher.merge(with: publisher)) + return publisher.merge(with: publisher).merge(with: publisher) .compactMap { $0 }.first() .eraseToAnyPublisher() } From 221f3dd59a7ab6588d420afe955ecd81e058e26f Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 15:11:17 -0800 Subject: [PATCH 04/27] Swift Dispatch scenario 11 --- .../Sources/EasyRacer/EasyRacer.swift | 66 +++++++++++++++++++ .../Tests/EasyRacerTests/EasyRacerTests.swift | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/swift-dispatch/Sources/EasyRacer/EasyRacer.swift b/swift-dispatch/Sources/EasyRacer/EasyRacer.swift index 9b9247c7..95b2d274 100644 --- a/swift-dispatch/Sources/EasyRacer/EasyRacer.swift +++ b/swift-dispatch/Sources/EasyRacer/EasyRacer.swift @@ -636,6 +636,71 @@ public struct EasyRacer { reportProcessLoad(startWallTime: currentWallTime(), startCPUTime: currentCPUTime()) } + func scenario11(scenarioHandler: @escaping @Sendable (String?) -> Void) { + let url: URL = baseURL.appendingPathComponent("11") + let urlSession: URLSession = URLSession(configuration: .ephemeral) + let outerRequestsGroup: DispatchGroup = DispatchGroup() + let innerRequestsGroup: DispatchGroup = DispatchGroup() + let expectedResponsesGroup: DispatchGroup = DispatchGroup() + var result: String? = nil + let resultLock: NSLock = NSLock() + expectedResponsesGroup.enter() // Expecting one response + + // Set up HTTP requests without executing + let innerDataTasks: [URLSessionDataTask] = (1...2) + .map { _ in + urlSession.bodyTextTask(with: url) { bodyText in + if case let .success(text) = bodyText { + resultLock.lock() + defer { resultLock.unlock() } + + if result == nil { + result = text + expectedResponsesGroup.leave() + } + } + innerRequestsGroup.leave() + } + } + let outerDataTask: URLSessionDataTask = urlSession.bodyTextTask(with: url) { bodyText in + if case let .success(text) = bodyText { + resultLock.lock() + defer { resultLock.unlock() } + + if result == nil { + result = text + expectedResponsesGroup.leave() + } + } + outerRequestsGroup.leave() + } + + // Executing requests, adding them to the DispatchGroup + outerRequestsGroup.enter() + for dataTask in innerDataTasks { + innerRequestsGroup.enter() + dataTask.resume() + } + innerRequestsGroup.notify(queue: .global()) { + outerRequestsGroup.leave() + } + outerRequestsGroup.enter() + outerDataTask.resume() + + // Got what we wanted, cancel remaining requests + expectedResponsesGroup.notify(queue: .global()) { + for dataTask in innerDataTasks { + dataTask.cancel() + } + outerDataTask.cancel() + } + + // Send result + outerRequestsGroup.notify(queue: .global()) { + scenarioHandler(result) + } + } + // Runs scenarios one by one, blocking until they are all complete public func scenarios(scenariosHandler: @escaping @Sendable ([String?]) -> Void) { let scenarios = [ @@ -649,6 +714,7 @@ public struct EasyRacer { (8, scenario8), (9, scenario9), (10, scenario10), + (11, scenario11), ] let completions: DispatchSemaphore = DispatchSemaphore(value: 0) func sortResultsAndNotify(results: [(Int, String?)]) { diff --git a/swift-dispatch/Tests/EasyRacerTests/EasyRacerTests.swift b/swift-dispatch/Tests/EasyRacerTests/EasyRacerTests.swift index a1c51824..455a271e 100644 --- a/swift-dispatch/Tests/EasyRacerTests/EasyRacerTests.swift +++ b/swift-dispatch/Tests/EasyRacerTests/EasyRacerTests.swift @@ -45,7 +45,7 @@ final class EasyRacerTests: XCTestCase { // Test let easyRacer = EasyRacer(baseURL: baseURL) easyRacer.scenarios { results in - XCTAssertEqual(results.count, 10, "Number of Scenarios") + XCTAssertEqual(results.count, 11, "Number of Scenarios") for (idx, result) in results.enumerated() { XCTAssertEqual(result, "right", "Scenario \(idx + 1)") } From c9abfbb55aae2832efb837a98423f7ad8e68f086 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 15:21:07 -0800 Subject: [PATCH 05/27] Update README.md to reflect swift-combine scenario 11 implementation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..28fea10c 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [Go conc](go-conc) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/go-conc.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + Grand Central Dispatch](swift-dispatch) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-dispatch.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + async/await](swift-async) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-async.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | -| [Swift + Combine](swift-combine) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-combine.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [Swift + Combine](swift-combine) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-combine.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Elm](elm-worker) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/elm-worker.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [JavaScript](javascript-stdlib) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/javascript-stdlib.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | Needs Scenario 10 Impl | | [Scala + Cats Effects 3](scala-ce3) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-ce3.yaml/badge.svg) | [Paul Snively](https://github.com/paul-snively) | Needs Scenario 10 Impl | From c7f64edf1c9949be84480fdacfd0bccee446d005 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 15:23:01 -0800 Subject: [PATCH 06/27] Update README.md to reflect swift-dispatch scenario 11 implementation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..ab8edd7e 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [Python + RxPy](python-rxpy) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-rxpy.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Go](go-stdlib) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/go-stdlib.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Go conc](go-conc) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/go-conc.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | -| [Swift + Grand Central Dispatch](swift-dispatch) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-dispatch.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [Swift + Grand Central Dispatch](swift-dispatch) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-dispatch.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + async/await](swift-async) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-async.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + Combine](swift-combine) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-combine.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Elm](elm-worker) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/elm-worker.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | From d94c28ca9930ed41c56b8364b07dc35ca97f10fe Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 15:39:33 -0800 Subject: [PATCH 07/27] Python RxPy scenario 11 --- README.md | 2 +- python-rxpy/main.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..f5b64125 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [OCaml + Lwt + Cohttp](ocaml-cohttp-lwt) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/ocaml-cohttp-lwt.yaml/badge.svg) | [Puneeth Chaganti](https://github.com/punchagan) | | | [OCaml + Eio + Cohttp](ocaml-cohttp-eio) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/ocaml-cohttp-eio.yaml/badge.svg) | [Puneeth Chaganti](https://github.com/punchagan) | | | [Python + AIOHTTP + TaskGroup](python-aiohttp-taskgroup) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-aiohttp-taskgroup.yaml/badge.svg) | [James Ward](https://github.com/jamesward) [Bruce Eckel](https://github.com/BruceEckel) | Needs Scenario 10 Impl | -| [Python + RxPy](python-rxpy) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-rxpy.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [Python + RxPy](python-rxpy) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-rxpy.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Go](go-stdlib) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/go-stdlib.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Go conc](go-conc) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/go-conc.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + Grand Central Dispatch](swift-dispatch) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-dispatch.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | diff --git a/python-rxpy/main.py b/python-rxpy/main.py index a941d465..707427ba 100644 --- a/python-rxpy/main.py +++ b/python-rxpy/main.py @@ -262,6 +262,19 @@ def handle_response(response: Response): # ) +def scenario11(url: str) -> rx.Observable[str]: + async def _req(): + async with aiohttp.ClientSession() as session: + async with session.get(url) as response: + return await response.text() + + def req(): return rx.from_future(asyncio.ensure_future(_req())) + + return rx.merge(rx.merge(req(), req()), req()) >> ops.first() + # Or: + # return rx.merge(rx.merge(req(), req()), req()).pipe(ops.first()) + + scenarios: list[Callable[[str], Coroutine[Any, Any, rx.Observable[str]]]] = [ scenario1, scenario2, @@ -273,6 +286,7 @@ def handle_response(response: Response): scenario8, scenario9, scenario10, + scenario11, ] From 6e37786473df1703c25092fba972ba8861f71e8a Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 15:43:45 -0800 Subject: [PATCH 08/27] Updated python-rxpy test scenarios count. --- python-rxpy/test_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-rxpy/test_all.py b/python-rxpy/test_all.py index 87b988fd..1606acb8 100644 --- a/python-rxpy/test_all.py +++ b/python-rxpy/test_all.py @@ -9,7 +9,7 @@ @pytest.mark.asyncio async def test_all(): - assert len(main.scenarios) == 10 + assert len(main.scenarios) == 11 # todo: no way to set pull policy yet docker_container = DockerContainer("ghcr.io/jamesward/easyracer").with_exposed_ports(8080) From 1cb06b4868778f503cbba871d65a277a15852df3 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 16:00:34 -0800 Subject: [PATCH 09/27] Upgrade to .NET 9.0. --- fsharp-reactive/EasyRacer.Tests/EasyRacer.Tests.fsproj | 4 ++-- fsharp-reactive/EasyRacer/EasyRacer.fs | 6 +++--- fsharp-reactive/EasyRacer/EasyRacer.fsproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fsharp-reactive/EasyRacer.Tests/EasyRacer.Tests.fsproj b/fsharp-reactive/EasyRacer.Tests/EasyRacer.Tests.fsproj index 645009fd..62b4be25 100644 --- a/fsharp-reactive/EasyRacer.Tests/EasyRacer.Tests.fsproj +++ b/fsharp-reactive/EasyRacer.Tests/EasyRacer.Tests.fsproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 false false true @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/fsharp-reactive/EasyRacer/EasyRacer.fs b/fsharp-reactive/EasyRacer/EasyRacer.fs index 99594855..a21a717e 100644 --- a/fsharp-reactive/EasyRacer/EasyRacer.fs +++ b/fsharp-reactive/EasyRacer/EasyRacer.fs @@ -35,7 +35,7 @@ let scenario4 (scenarioGet: string -> IObservable) : IObser let reqWithTimeout = req - |> Observable.timeoutSpan (TimeSpan.FromSeconds 1) + |> Observable.timeoutSpan (TimeSpan.FromSeconds 1.0) |> Observable.take 1 |> Observable.catch Observable.empty @@ -64,7 +64,7 @@ let scenario7 (scenarioGet: string -> IObservable) : IObser |> Observable.bind (fun resp -> resp.Content.ReadAsStringAsync() |> Async.AwaitTask |> Observable.ofAsync) let reqWithDelay = - Observable.delay (TimeSpan.FromSeconds 3) (Observable.single ()) + Observable.delay (TimeSpan.FromSeconds 3.0) (Observable.single ()) |> Observable.bind (fun () -> req) Observable.merge req reqWithDelay |> Observable.take 1 @@ -142,7 +142,7 @@ let scenario10 (scenarioGet: string -> IObservable) : IObse -> Observable.single ($"bad HTTP status: {resp.StatusCode}") | resp -> - Observable.delay (TimeSpan.FromSeconds 1) (Observable.single ()) + Observable.delay (TimeSpan.FromSeconds 1.0) (Observable.single ()) |> Observable.bind (fun () -> reportProcessLoad endWallTime endCpuTime)) let reporter = reportProcessLoad DateTime.Now proc.TotalProcessorTime diff --git a/fsharp-reactive/EasyRacer/EasyRacer.fsproj b/fsharp-reactive/EasyRacer/EasyRacer.fsproj index bfa4f410..abfe6bd8 100644 --- a/fsharp-reactive/EasyRacer/EasyRacer.fsproj +++ b/fsharp-reactive/EasyRacer/EasyRacer.fsproj @@ -1,7 +1,7 @@ Exe - net8.0 + net9.0 @@ -10,4 +10,4 @@ - \ No newline at end of file + From c4c3a6c1c33cd80d42da5c0d8c16ebc18a7ba1a4 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 16:03:07 -0800 Subject: [PATCH 10/27] Updated F# GitHub Actions workflow to use .NET 9.0. --- .github/workflows/clients.pkl | 2 +- .github/workflows/fsharp-reactive.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clients.pkl b/.github/workflows/clients.pkl index db69c2b1..117cfe93 100644 --- a/.github/workflows/clients.pkl +++ b/.github/workflows/clients.pkl @@ -31,7 +31,7 @@ clients = new Mapping { } ["fsharp-reactive"] = new { - steps = GitHubAction.Dotnet.testSteps(null, "8.0.x", "./fsharp-reactive/EasyRacer.Tests") + steps = GitHubAction.Dotnet.testSteps(null, "9.0.x", "./fsharp-reactive/EasyRacer.Tests") } ["go-conc"] = new { diff --git a/.github/workflows/fsharp-reactive.yaml b/.github/workflows/fsharp-reactive.yaml index 38113b63..fe6b7f4a 100644 --- a/.github/workflows/fsharp-reactive.yaml +++ b/.github/workflows/fsharp-reactive.yaml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - run: dotnet test working-directory: ./fsharp-reactive/EasyRacer.Tests defaults: From 22d7577bfb0b9573ffaae4d7a8478f4363cd4845 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 16:50:06 -0800 Subject: [PATCH 11/27] F# Reactive scenario 11. --- fsharp-reactive/EasyRacer/EasyRacer.fs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fsharp-reactive/EasyRacer/EasyRacer.fs b/fsharp-reactive/EasyRacer/EasyRacer.fs index a21a717e..d10914dd 100644 --- a/fsharp-reactive/EasyRacer/EasyRacer.fs +++ b/fsharp-reactive/EasyRacer/EasyRacer.fs @@ -154,6 +154,13 @@ let scenario10 (scenarioGet: string -> IObservable) : IObse |> Observable.filter (fun text -> text <> "") |> Observable.take 1 +let scenario11 (scenarioGet: string -> IObservable) : IObservable = + let req = + scenarioGet "/11" + |> Observable.bind (fun resp -> resp.Content.ReadAsStringAsync() |> Async.AwaitTask |> Observable.ofAsync) + + Observable.merge req req |> Observable.merge req |> Observable.take 1 + let scenarios: ((string -> IObservable) -> IObservable) array = [| scenario1 scenario2 @@ -164,7 +171,8 @@ let scenarios: ((string -> IObservable) -> IObservable] let main _ = From 1d2c30f740a5bb8b369d679fa49e13993d1f6c78 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:23:13 -0800 Subject: [PATCH 12/27] Updated README.md to reflect F# Reactive scenario 11 addition --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..d311e5ef 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [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 | -| [F# + Reactive Extensions](fsharp-reactive) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/fsharp-reactive.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [F# + Reactive Extensions](fsharp-reactive) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/fsharp-reactive.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [OCaml + Lwt + Cohttp](ocaml-cohttp-lwt) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/ocaml-cohttp-lwt.yaml/badge.svg) | [Puneeth Chaganti](https://github.com/punchagan) | | | [OCaml + Eio + Cohttp](ocaml-cohttp-eio) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/ocaml-cohttp-eio.yaml/badge.svg) | [Puneeth Chaganti](https://github.com/punchagan) | | | [Python + AIOHTTP + TaskGroup](python-aiohttp-taskgroup) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-aiohttp-taskgroup.yaml/badge.svg) | [James Ward](https://github.com/jamesward) [Bruce Eckel](https://github.com/BruceEckel) | Needs Scenario 10 Impl | From 900bd2a787f925e0f7c8f7569444f9a69920934f Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:29:28 -0800 Subject: [PATCH 13/27] Kotlin Flow scenario 11 --- README.md | 2 +- kotlin-flow/src/main/kotlin/Main.kt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..3d55db0f 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [Scala 3 + Gears](scala-gears) | 10/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) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-akkastreams.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Kotlin + Coroutines](kotlin-coroutines) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-coroutines.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | -| [Kotlin + Flow](kotlin-flow) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-flow.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) | | diff --git a/kotlin-flow/src/main/kotlin/Main.kt b/kotlin-flow/src/main/kotlin/Main.kt index 096fce77..637d4198 100644 --- a/kotlin-flow/src/main/kotlin/Main.kt +++ b/kotlin-flow/src/main/kotlin/Main.kt @@ -134,6 +134,12 @@ suspend fun scenario10(url: (Int) -> String): String { return merge(blocker, reporter()).filterNotNull().first() } +suspend fun scenario11(url: (Int) -> String): String { + val req = client.getAsFlow(url(1)).map { it.bodyAsText() } + + return merge(merge(req, req), req).first() +} + val scenarios = listOf( ::scenario1, ::scenario2, @@ -145,6 +151,7 @@ val scenarios = listOf( ::scenario8, ::scenario9, ::scenario10, + ::scenario11, ) suspend fun results(url: (Int) -> String) = scenarios.map { From 68d97b22d19dc781ec626dd755bf4b5bf29df182 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:35:54 -0800 Subject: [PATCH 14/27] Actually use scenario 11 URL for Kotlin Flow scenario 11. --- kotlin-flow/src/main/kotlin/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-flow/src/main/kotlin/Main.kt b/kotlin-flow/src/main/kotlin/Main.kt index 637d4198..3e511ada 100644 --- a/kotlin-flow/src/main/kotlin/Main.kt +++ b/kotlin-flow/src/main/kotlin/Main.kt @@ -135,7 +135,7 @@ suspend fun scenario10(url: (Int) -> String): String { } suspend fun scenario11(url: (Int) -> String): String { - val req = client.getAsFlow(url(1)).map { it.bodyAsText() } + val req = client.getAsFlow(url(11)).map { it.bodyAsText() } return merge(merge(req, req), req).first() } From e293f5df4ae5f38ed88a5cae554fd61ce5247063 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:37:05 -0800 Subject: [PATCH 15/27] Scala Akka Streams scenario 11 --- README.md | 2 +- scala-akkastreams/src/main/scala/EasyRacerClient.scala | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7dcf2eb3..4de4f74b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [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 + Gears](scala-gears) | 10/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) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-akkastreams.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) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-coroutines.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Kotlin + Flow](kotlin-flow) | 10/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) | | diff --git a/scala-akkastreams/src/main/scala/EasyRacerClient.scala b/scala-akkastreams/src/main/scala/EasyRacerClient.scala index 5affa50d..4eccdd55 100644 --- a/scala-akkastreams/src/main/scala/EasyRacerClient.scala +++ b/scala-akkastreams/src/main/scala/EasyRacerClient.scala @@ -176,8 +176,16 @@ object EasyRacerClient: .dropWhile(_ == "") .take(1) + val scenario11: Flow[HttpFlow, String, NotUsed] = + Flow[HttpFlow].map(scenarioRequestFlow).flatMapConcat: scenarioReq => + val path = Uri("/11") + val req = Source.single(path).via(scenarioReq).collect: + case Success((_, body)) => body + + req.merge(req).merge(req).take(1) + val scenarios: Seq[Flow[HttpFlow, String, NotUsed]] = - Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10) + Seq(scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10, scenario11) @main def run(): Unit = import EasyRacerClient.* From ff9166299ac8372225ecbe2310222cd0215ae2c3 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:43:23 -0800 Subject: [PATCH 16/27] Properly handle Kotlin Flow scenario 11 exception. --- kotlin-flow/src/main/kotlin/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-flow/src/main/kotlin/Main.kt b/kotlin-flow/src/main/kotlin/Main.kt index 3e511ada..e1ec92b0 100644 --- a/kotlin-flow/src/main/kotlin/Main.kt +++ b/kotlin-flow/src/main/kotlin/Main.kt @@ -135,7 +135,7 @@ suspend fun scenario10(url: (Int) -> String): String { } suspend fun scenario11(url: (Int) -> String): String { - val req = client.getAsFlow(url(11)).map { it.bodyAsText() } + val req = client.getAsFlow(url(11)).catch {}.map { it.bodyAsText() } return merge(merge(req, req), req).first() } From 697a1cd744eed9a71675220965da6e920c97f500 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 17:52:36 -0800 Subject: [PATCH 17/27] Kotlin Coroutines scenario 11 --- README.md | 2 +- kotlin-coroutines/src/main/kotlin/Main.kt | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dcf2eb3..834d81f6 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [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 + Gears](scala-gears) | 10/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) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-akkastreams.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | -| [Kotlin + Coroutines](kotlin-coroutines) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-coroutines.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) | 10/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) | | diff --git a/kotlin-coroutines/src/main/kotlin/Main.kt b/kotlin-coroutines/src/main/kotlin/Main.kt index 785e2328..f9451f6a 100644 --- a/kotlin-coroutines/src/main/kotlin/Main.kt +++ b/kotlin-coroutines/src/main/kotlin/Main.kt @@ -217,6 +217,28 @@ suspend fun scenario10(url: (Int) -> String): String = coroutineScope { reporter() } +suspend fun scenario11(url: (Int) -> String): String = coroutineScope { + suspend fun req(): HttpResponse = + try { + client.get(url(11)) + } catch (_: Exception) { + awaitCancellation() + } + try { + select { + async { + select { + async { req() }.onAwait { it } + async { req() }.onAwait { it } + } + } + async { req() }.onAwait { it } + }.bodyAsText() + } finally { + coroutineContext.cancelChildren() + } +} + val scenarios = listOf( ::scenario1, ::scenario2, @@ -228,6 +250,7 @@ val scenarios = listOf( ::scenario8, ::scenario9, ::scenario10, + ::scenario11, ) suspend fun results(url: (Int) -> String) = scenarios.map { From 8e264a38bb872e22aa448a24b2360128f00adc5d Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 20:01:59 -0800 Subject: [PATCH 18/27] Elm Worker scenario 11 --- README.md | 2 +- elm-worker/src/EasyRacer/Scenario11.elm | 94 +++++++++++++++++++++++++ elm-worker/tests/EasyRacer.test.js | 2 +- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 elm-worker/src/EasyRacer/Scenario11.elm diff --git a/README.md b/README.md index 7dcf2eb3..b8958025 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [Swift + Grand Central Dispatch](swift-dispatch) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-dispatch.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + async/await](swift-async) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-async.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Swift + Combine](swift-combine) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/swift-combine.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | -| [Elm](elm-worker) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/elm-worker.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [Elm](elm-worker) | 11/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/elm-worker.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [JavaScript](javascript-stdlib) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/javascript-stdlib.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | Needs Scenario 10 Impl | | [Scala + Cats Effects 3](scala-ce3) | 9/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-ce3.yaml/badge.svg) | [Paul Snively](https://github.com/paul-snively) | Needs Scenario 10 Impl | | [Python + HTTPX + Trio](python-httpx-trio) | 8/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/python-httpx-trio.yaml/badge.svg) | [James Ward](https://github.com/jamesward) | Needs Scenarios 3, 10 | diff --git a/elm-worker/src/EasyRacer/Scenario11.elm b/elm-worker/src/EasyRacer/Scenario11.elm new file mode 100644 index 00000000..1505127d --- /dev/null +++ b/elm-worker/src/EasyRacer/Scenario11.elm @@ -0,0 +1,94 @@ +module EasyRacer.Scenario11 exposing (main) + +-- Elm does not really have a higher-level racing construct +-- We are building everything by hand anyway, so this is basically just scenario 6 + +import EasyRacer.Ports as Ports +import Http +import Platform exposing (Program) +import Set exposing (Set) + + +type alias Flags = + String + + +type alias Model = + { inflightTrackers : Set String + } + + +type Msg + = HttpResponse String (Result Http.Error String) + + +scenarioPath : String +scenarioPath = + "/11" + + +init : Flags -> ( Model, Cmd Msg ) +init baseUrl = + let + requestTrackers = + [ "first", "second", "third" ] + + httpRequest tracker = + { method = "GET" + , headers = [] + , url = baseUrl ++ scenarioPath + , body = Http.emptyBody + , expect = Http.expectString (HttpResponse tracker) + , timeout = Nothing + , tracker = Just tracker + } + in + ( { inflightTrackers = Set.fromList requestTrackers + } + , requestTrackers + |> List.map (Http.request << httpRequest) + |> Cmd.batch + ) + + +update : Msg -> Model -> ( Model, Cmd Msg ) +update msg model = + case msg of + HttpResponse tracker httpResult -> + let + remainingTrackers : Set String + remainingTrackers = + model.inflightTrackers |> Set.remove tracker + in + ( { model | inflightTrackers = remainingTrackers } + , case httpResult of + Ok bodyText -> + let + cancellations : List (Cmd Msg) + cancellations = + remainingTrackers + |> Set.toList + |> List.map Http.cancel + + returnResult : Cmd Msg + returnResult = + Ok bodyText |> Ports.sendResult + in + returnResult :: cancellations |> Cmd.batch + + Err _ -> + if not <| Set.isEmpty remainingTrackers then + Cmd.none + + else + Err "all requests completed without a single success response" |> Ports.sendResult + ) + + +main : Program Flags Model Msg +main = + Platform.worker + { init = init + , update = update + , subscriptions = always Sub.none + } diff --git a/elm-worker/tests/EasyRacer.test.js b/elm-worker/tests/EasyRacer.test.js index 6d61b5db..b10cbf37 100644 --- a/elm-worker/tests/EasyRacer.test.js +++ b/elm-worker/tests/EasyRacer.test.js @@ -15,7 +15,7 @@ describe("EasyRacer", () => { await container.stop(); }); - for (const idx of Array(10).keys()) { + for (const idx of Array(11).keys()) { const scenarioNum = idx + 1; it("scenario " + scenarioNum, async () => { const name = "Scenario" + scenarioNum; From 4994f984fb20b83d487b92280d4989d979fc2190 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 20:03:03 -0800 Subject: [PATCH 19/27] Update Elm Workers GitHub Actions. --- .github/workflows/clients.pkl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clients.pkl b/.github/workflows/clients.pkl index db69c2b1..1d8833eb 100644 --- a/.github/workflows/clients.pkl +++ b/.github/workflows/clients.pkl @@ -19,7 +19,7 @@ clients = new Mapping { new { run = """ echo Compiling Elm sources... - for num in {1..10}; do + for num in {1..11}; do elm make --optimize --output=app/EasyRacer/Scenario$num.js src/EasyRacer/Scenario$num.elm done npm install --no-fund From aef02cef9b572b398e52989ea9205d171febd7aa Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 20:21:33 -0800 Subject: [PATCH 20/27] Fixed Kotlin Coroutines scenario 11. --- kotlin-coroutines/src/main/kotlin/Main.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kotlin-coroutines/src/main/kotlin/Main.kt b/kotlin-coroutines/src/main/kotlin/Main.kt index f9451f6a..a6073f07 100644 --- a/kotlin-coroutines/src/main/kotlin/Main.kt +++ b/kotlin-coroutines/src/main/kotlin/Main.kt @@ -226,12 +226,18 @@ suspend fun scenario11(url: (Int) -> String): String = coroutineScope { } try { select { - async { - select { - async { req() }.onAwait { it } - async { req() }.onAwait { it } - } - } + try { + async { + try { + select { + async { req() }.onAwait { it } + async { req() }.onAwait { it } + } + } finally { + coroutineContext.cancelChildren() + } + }.onAwait { it } + } catch (_: Exception) {} async { req() }.onAwait { it } }.bodyAsText() } finally { From 379ad9392ee9d017220290c8c373e3e8d8c74896 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 20:23:55 -0800 Subject: [PATCH 21/27] Updated elm-worker.yaml. --- .github/workflows/elm-worker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elm-worker.yaml b/.github/workflows/elm-worker.yaml index db6b623f..84b2a924 100644 --- a/.github/workflows/elm-worker.yaml +++ b/.github/workflows/elm-worker.yaml @@ -24,7 +24,7 @@ jobs: elm-version: 0.19.1 - run: |- echo Compiling Elm sources... - for num in {1..10}; do + for num in {1..11}; do elm make --optimize --output=app/EasyRacer/Scenario$num.js src/EasyRacer/Scenario$num.elm done npm install --no-fund From c6861db88367d1099840157c01ec288bcfe93393 Mon Sep 17 00:00:00 2001 From: Jack Leow Date: Sun, 22 Dec 2024 20:33:15 -0800 Subject: [PATCH 22/27] Scala Gears scenario 11 --- README.md | 2 +- scala-gears/src/main/scala/EasyRacerClient.scala | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7dcf2eb3..bdf547c2 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ docker run -it -p8080:8080 ghcr.io/jamesward/easyracer --debug | [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 + Gears](scala-gears) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-gears.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | +| [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) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/scala-akkastreams.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Kotlin + Coroutines](kotlin-coroutines) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-coroutines.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | | [Kotlin + Flow](kotlin-flow) | 10/11 ![tests](https://github.com/jamesward/easyracer/actions/workflows/kotlin-flow.yaml/badge.svg) | [Jack Leow](https://github.com/jackgene) | | diff --git a/scala-gears/src/main/scala/EasyRacerClient.scala b/scala-gears/src/main/scala/EasyRacerClient.scala index cd1a1a7f..b3c48800 100644 --- a/scala-gears/src/main/scala/EasyRacerClient.scala +++ b/scala-gears/src/main/scala/EasyRacerClient.scala @@ -175,8 +175,17 @@ object EasyRacerClient: blocker.awaitFirstWithCancel result.await + def scenario11(scenarioUrl: Int => String)(using Async.Spawn): String = + val url = scenarioUrl(11) + + def req = Future(scenarioRequest(url).asyncGet.getResponseBody) + + req.orWithCancel(req).orWithCancel(req).await + // Or: +// Async.race(Async.race(req, req), req).await + def scenarios: Seq[(Int => String) => Async.Spawn ?=> String] = Seq( - scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10 + scenario1, scenario2, scenario3, scenario4, scenario5, scenario6, scenario7, scenario8, scenario9, scenario10, scenario11 ) @main def run(): Unit = From 503ca63a295a169af9b226d1d1ba76e0f3f3458a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:32:38 +0000 Subject: [PATCH 23/27] Bump org.junit.jupiter:junit-jupiter from 5.11.3 to 5.11.4 in /java-loom Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.11.3 to 5.11.4. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.3...r5.11.4) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- java-loom/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-loom/build.gradle.kts b/java-loom/build.gradle.kts index f42ad415..29c846c6 100644 --- a/java-loom/build.gradle.kts +++ b/java-loom/build.gradle.kts @@ -13,7 +13,7 @@ repositories { } dependencies { - testImplementation("org.junit.jupiter:junit-jupiter:5.11.3") + testImplementation("org.junit.jupiter:junit-jupiter:5.11.4") testImplementation("org.testcontainers:testcontainers:1.20.4") testImplementation("org.testcontainers:junit-jupiter:1.20.4") testRuntimeOnly("org.slf4j:slf4j-simple:2.0.16") From 26b4beb6672627ee63308e67d17016e75b5536ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:33:12 +0000 Subject: [PATCH 24/27] Bump io.ktor:ktor-client-core from 3.0.2 to 3.0.3 in /kotlin-coroutines Bumps [io.ktor:ktor-client-core](https://github.com/ktorio/ktor) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/ktorio/ktor/releases) - [Changelog](https://github.com/ktorio/ktor/blob/main/CHANGELOG.md) - [Commits](https://github.com/ktorio/ktor/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: io.ktor:ktor-client-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- kotlin-coroutines/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-coroutines/build.gradle.kts b/kotlin-coroutines/build.gradle.kts index 614b7ad0..71aa955b 100644 --- a/kotlin-coroutines/build.gradle.kts +++ b/kotlin-coroutines/build.gradle.kts @@ -17,7 +17,7 @@ application { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("io.ktor:ktor-client-core:3.0.2") + implementation("io.ktor:ktor-client-core:3.0.3") implementation("io.ktor:ktor-client-java:3.0.2") testImplementation("io.kotest:kotest-runner-junit5:5.9.1") From 55ad64e590185594d55db6e9af8764aa0b74fd0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:41:27 +0000 Subject: [PATCH 25/27] Bump io.ktor:ktor-client-java from 3.0.2 to 3.0.3 in /kotlin-splitties Bumps [io.ktor:ktor-client-java](https://github.com/ktorio/ktor) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/ktorio/ktor/releases) - [Changelog](https://github.com/ktorio/ktor/blob/main/CHANGELOG.md) - [Commits](https://github.com/ktorio/ktor/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: io.ktor:ktor-client-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- kotlin-splitties/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-splitties/build.gradle.kts b/kotlin-splitties/build.gradle.kts index 95004368..1367dd2e 100644 --- a/kotlin-splitties/build.gradle.kts +++ b/kotlin-splitties/build.gradle.kts @@ -20,7 +20,7 @@ application { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") implementation("io.ktor:ktor-client-core:3.0.2") - implementation("io.ktor:ktor-client-java:3.0.2") + implementation("io.ktor:ktor-client-java:3.0.3") implementation("com.louiscad.splitties:splitties-coroutines:3.0.0") runtimeOnly("org.slf4j:slf4j-simple:2.0.16") From 28bf76f09165963f4939ffb07b30e215a3c55f13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:41:31 +0000 Subject: [PATCH 26/27] Bump org.jetbrains.kotlinx:kotlinx-coroutines-core in /kotlin-splitties Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-core](https://github.com/Kotlin/kotlinx.coroutines) from 1.9.0 to 1.10.1. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.9.0...1.10.1) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- kotlin-splitties/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-splitties/build.gradle.kts b/kotlin-splitties/build.gradle.kts index 95004368..989b43c5 100644 --- a/kotlin-splitties/build.gradle.kts +++ b/kotlin-splitties/build.gradle.kts @@ -18,7 +18,7 @@ application { } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") implementation("io.ktor:ktor-client-core:3.0.2") implementation("io.ktor:ktor-client-java:3.0.2") implementation("com.louiscad.splitties:splitties-coroutines:3.0.0") From 3dbed325d485bc545479617bd194de8e7b3ee39f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:54:40 +0000 Subject: [PATCH 27/27] Bump io.ktor:ktor-client-core from 3.0.2 to 3.0.3 in /kotlin-arrow Bumps [io.ktor:ktor-client-core](https://github.com/ktorio/ktor) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/ktorio/ktor/releases) - [Changelog](https://github.com/ktorio/ktor/blob/main/CHANGELOG.md) - [Commits](https://github.com/ktorio/ktor/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: io.ktor:ktor-client-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- kotlin-arrow/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-arrow/build.gradle.kts b/kotlin-arrow/build.gradle.kts index 9d34b1b5..4b0ab954 100644 --- a/kotlin-arrow/build.gradle.kts +++ b/kotlin-arrow/build.gradle.kts @@ -19,7 +19,7 @@ application { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("io.ktor:ktor-client-core:3.0.2") + implementation("io.ktor:ktor-client-core:3.0.3") implementation("io.ktor:ktor-client-java:3.0.2") implementation("io.arrow-kt:arrow-fx-coroutines:2.0.0") runtimeOnly("org.slf4j:slf4j-simple:2.0.16")