http_gun/deadline

A monotonic time budget shared by several calls on one VM.

Create one with after before a unit of work and give each request the remaining budget with http_gun.with_deadline:

let budget = deadline.after(duration.seconds(60))
let client = client |> http_gun.with_deadline(budget)
let first = http_gun.send(client, first_request)
let second = http_gun.send(client, second_request) // shares the 60 s

A Deadline is VM-local: do not persist it or send it to another node.

Types

pub opaque type Deadline

Values

pub fn after(budget: duration.Duration) -> Deadline

A budget that ends budget from now, in whole milliseconds. Zero or a negative budget is already expired.

pub fn remaining(deadline: Deadline) -> duration.Duration

The time left, in whole milliseconds and clamped to zero. Reading does not renew it.

✨ Search Document