From 1387c48e53314584ccf3d28cd9775312d3ecca04 Mon Sep 17 00:00:00 2001 From: Guillaume Hivert Date: Mon, 2 Dec 2024 15:10:26 +0100 Subject: [PATCH] Update prng package --- apps/backend/gleam.toml | 4 ++-- apps/backend/manifest.toml | 6 +++--- apps/backend/src/processes/retrier.gleam | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/backend/gleam.toml b/apps/backend/gleam.toml index 5b4d239..cefe25e 100644 --- a/apps/backend/gleam.toml +++ b/apps/backend/gleam.toml @@ -22,9 +22,9 @@ glexer = ">= 1.0.1 and < 2.0.0" interfaces = {path = "../../packages/interfaces"} mist = ">= 3.0.0 and < 4.0.0" pog = ">= 1.0.1 and < 2.0.0" -prng = ">= 3.0.3 and < 4.0.0" +prng = ">= 4.0.0 and < 5.0.0" radiate = ">= 0.4.0 and < 1.0.0" -ranger = ">= 1.2.0 and < 2.0.0" +ranger = ">= 1.3.0 and < 2.0.0" simplifile = ">= 2.1.0 and < 3.0.0" tom = ">= 1.1.0 and < 2.0.0" verl = ">= 1.1.1 and < 2.0.0" diff --git a/apps/backend/manifest.toml b/apps/backend/manifest.toml index 618c275..1a441d0 100644 --- a/apps/backend/manifest.toml +++ b/apps/backend/manifest.toml @@ -42,7 +42,7 @@ packages = [ { name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" }, { name = "pog", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "pgo"], otp_app = "pog", source = "hex", outer_checksum = "48D6570C1E98F77A3C29E7ED4F1D81205DD0D870DCEC55F536EF3A57A28DF627" }, { name = "pprint", version = "1.0.4", build_tools = ["gleam"], requirements = ["glam", "gleam_stdlib"], otp_app = "pprint", source = "hex", outer_checksum = "C310A98BDC0995644847C3C8702DE19656D6BCD638B2A8A358B97824379ECAA1" }, - { name = "prng", version = "3.0.3", build_tools = ["gleam"], requirements = ["gleam_bitwise", "gleam_stdlib"], otp_app = "prng", source = "hex", outer_checksum = "53006736FE23A0F61828C95B505193E10905D8DB76E128F1642D3E571E08F589" }, + { name = "prng", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_bitwise", "gleam_stdlib", "gleam_yielder"], otp_app = "prng", source = "hex", outer_checksum = "E452F957D19CCDC1B4BD12AA6E1B33194B1EB9C2BC0B3449D96E3585602EE3AE" }, { name = "radiate", version = "0.4.0", build_tools = ["gleam"], requirements = ["filespy", "gleam_otp", "gleam_stdlib", "shellout"], otp_app = "radiate", source = "hex", outer_checksum = "93A76A66EE4741DBFD3E79E27CBD11FE58EC3CB1C58F017FC165944E339D6293" }, { name = "ranger", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "B8F3AFF23A3A5B5D9526B8D18E7C43A7DFD3902B151B97EC65397FE29192B695" }, { name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" }, @@ -77,9 +77,9 @@ interfaces = { path = "../../packages/interfaces" } mist = { version = ">= 3.0.0 and < 4.0.0" } pog = { version = ">= 1.0.1 and < 2.0.0" } pprint = { version = ">= 1.0.3 and < 2.0.0" } -prng = { version = ">= 3.0.3 and < 4.0.0" } +prng = { version = ">= 4.0.0 and < 5.0.0" } radiate = { version = ">= 0.4.0 and < 1.0.0" } -ranger = { version = ">= 1.2.0 and < 2.0.0" } +ranger = { version = ">= 1.3.0 and < 2.0.0" } simplifile = { version = ">= 2.1.0 and < 3.0.0" } tom = { version = ">= 1.1.0 and < 2.0.0" } verl = { version = ">= 1.1.1 and < 2.0.0" } diff --git a/apps/backend/src/processes/retrier.gleam b/apps/backend/src/processes/retrier.gleam index 2ee1c0f..d426571 100644 --- a/apps/backend/src/processes/retrier.gleam +++ b/apps/backend/src/processes/retrier.gleam @@ -2,8 +2,8 @@ import backend/error.{type Error} import gleam/bool import gleam/erlang/process.{type Subject} import gleam/function -import gleam/iterator.{type Iterator} import gleam/otp/actor +import gleam/yielder.{type Yielder} import prng/random import wisp @@ -15,7 +15,7 @@ type State(a) { State( self: Subject(Message), work: fn(Int) -> Result(a, Error), - random_ints: Iterator(Int), + random_ints: Yielder(Int), interval: Int, iterations: Int, ) @@ -24,7 +24,7 @@ type State(a) { pub const one_minute: Int = 60_000 fn enqueue_next_rerun(state: State(a)) { - let assert iterator.Next(cooldown, acc) = iterator.step(state.random_ints) + let assert yielder.Next(cooldown, acc) = yielder.step(state.random_ints) process.send_after(state.self, state.interval + cooldown, Rerun) State(..state, random_ints: acc) } @@ -47,7 +47,7 @@ fn init( do work: fn(Int) -> Result(a, Error), ) -> actor.InitResult(State(a), Message) { let self = process.new_subject() - let random_ints = random.to_random_iterator(random.int(1000, 5000)) + let random_ints = random.to_random_yielder(random.int(1000, 5000)) let state = State(self:, work:, interval:, iterations: 10, random_ints:) process.new_selector() |> process.selecting(self, function.identity)