Skip to content

Commit

Permalink
Update prng package
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Dec 2, 2024
1 parent e94fa01 commit 1387c48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/backend/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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" }
Expand Down
8 changes: 4 additions & 4 deletions apps/backend/src/processes/retrier.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
)
Expand All @@ -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)
}
Expand All @@ -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)
Expand Down

0 comments on commit 1387c48

Please sign in to comment.