pub struct Gate { /* private fields */ }Expand description
Closed by a 429 for every request, reads and actions alike: the venue limits by IP, so one refusal means the next request would be refused too.
Implementations§
Source§impl Gate
impl Gate
Sourcepub fn open(&self, now: u64) -> Result<Ticket, u64>
pub fn open(&self, now: u64) -> Result<Ticket, u64>
A ticket out, or how long the gate stays closed.
Sourcepub fn passed(&mut self, ticket: Ticket)
pub fn passed(&mut self, ticket: Ticket)
The request was answered: room again, unless a 429 struck since it went out.
Sourcepub fn struck(
&mut self,
ticket: Ticket,
now: u64,
retry_after_ms: Option<u64>,
) -> u64
pub fn struck( &mut self, ticket: Ticket, now: u64, retry_after_ms: Option<u64>, ) -> u64
A 429 came back at now. The first of a burst strikes: two seconds,
doubling to a minute, or a longer Retry-After. The rest of the burst
only moves the gate for a longer Retry-After. Gives the wait.
pub const fn cooldown_ms(&self, now: u64) -> u64
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gate
impl RefUnwindSafe for Gate
impl Send for Gate
impl Sync for Gate
impl Unpin for Gate
impl UnsafeUnpin for Gate
impl UnwindSafe for Gate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more