letbackoff
pub let backoff : @moonward.Backoff
Reference
Every public type, method and value of the package. A signature is what the compiler reports, and the note under it is the one written beside the code.
1 package · 28 public items
A pool of resources with no I/O of its own: it says which resource to hand out, whether to make another, which to let go, and when to refuse, and leaves the acting to the caller.
pub let backoff : @moonward.Backoff
A span meaning "no limit", which is what zero is taken to mean for the two ages: a resource with no maximum age is never too old.
pub let forever : @moondate.Span
The preset: ten live at once, ten of them allowed to sit idle, discarded after thirty minutes idle and never by age. Ten live is what most services settle on, and thirty minutes is long enough that a warm pool survives a quiet spell. Keeping idle equal to size means a pool that grew under load does not immediately throw away what it just made.
pub let limits : Limits
pub let ward : Ward
The limits a pool holds itself to. The preset is limits. Build another with Limits::new, or update one in place with { ..limits, size: 32 }.
pub(all) struct Limits {
Limits by name, every knob with the preset's value.
pub fn Limits::new(size? : Int32, idle? : Int32, keep? : @moondate.Span, life? : @moondate.Span) -> Self
The bookkeeping of holding a limited number of things. It does not open, close, or wait — a caller with a runtime does all three. What it knows is how many are live, which are idle, which are lent and since when each was made, and which have sat or lived long enough to be let go. Time is passed in as whatever the caller's clock reads, in nanoseconds; the value's origin does not matter because only differences are used. That is what makes a test drive a pool through an hour in three lines. A lent resource is recognised on its way back by identity, which is what every connection handle has. That is how its birth survives the loan: a pool that stamped a returned resource as new would never retire one by age, however old. Idle resources are kept as (item, born, rested), lent ones as (item, born, ticket), and each resource being made as the breaker's promise and the shedder's ticket it will settle.
type Pool[T]
pub fn[T] Pool::busy(Self[T]) -> Int32
pub fn[T] Pool::close(Self[T]) -> Array[T]
pub fn[T] Pool::drop(Self[T], T) -> Unit
pub fn[T] Pool::evict(Self[T], Int64) -> Array[T]
pub fn[T] Pool::give(Self[T], T, Int64) -> Bool
pub fn[T] Pool::idle(Self[T]) -> Int32
pub fn[T] Pool::live(Self[T]) -> Int32
pub fn[T] Pool::made(Self[T], T, Int64) -> Unit
pub fn[T] Pool::new(limits? : Limits, ward? : Ward) -> Self[T]
pub fn[T] Pool::refusal(Self[T], Int64) -> Double
pub fn[T] Pool::take(Self[T], Int64, roll? : Double, cpu? : Int32) -> Taken[T]
pub fn[T] Pool::unmade(Self[T], Int64, roll? : Double) -> Unit
What a pool answers when asked for a resource. It never blocks and never opens anything: waiting and connecting both need a runtime, and this package has none. Make is the pool saying there is room for another, and reserving it; Wait is it saying there is not, and the caller's queue decides what that means. Stale is an idle resource too old to use, handed back so the caller can close it before asking again. The last two come only from a Ward: Later is making held back for that long, by the bucket or by backoff after a failure; Shed is the breaker refusing new connections to a failing backend, or the shedder refusing to lend while the process is overloaded.
pub(all) enum Taken[T] {
What stands in front of a pool's backend. Every part is optional and the preset has none, which leaves the pool exactly as it is without a ward.
pub(all) struct Ward {
pub fn Ward::new(breaker? : @moonward.Breaker, bucket? : @moonward.Bucket, backoff? : @moonward.Backoff, shedder? : @moonward.Shedder) -> Self
pub fn[T] pick(ArrayView[Pool[T]], Int64, first~ : Double, second~ : Double) -> Int32
An alias of a type the ward's parts are made of, so a pool can be described without naming where each part lives.
type Backoff
An alias of a type the ward's parts are made of, so a pool can be described without naming where each part lives.
type Bucket
An alias of a type the ward's parts are made of, so a pool can be described without naming where each part lives.
type Gate
An alias of a type the ward's parts are made of, so a pool can be described without naming where each part lives.
type Jitter
An alias of a type the ward's parts are made of, so a pool can be described without naming where each part lives.
type Sliding