Skip to main content

Module throttle

Module throttle 

Source
Expand description

Keeping outbound requests to a polite rate.

The Advent of Code automation guidelines ask that automated tools do not hammer the site. This tool never polls and never runs on a schedule, so every request it makes is one a person asked for; what needs controlling is bursts. A single aoc run --submit would otherwise fetch an input and post two answers back to back, and nothing would stop a shell loop from repeating that as fast as the network allows.

Throttle enforces a minimum gap between requests. The moment of the last request is remembered in the state directory as well as in memory, so the gap survives across separate invocations of the binary instead of only holding within one.

Structs§

SystemTimer
A timer backed by the system clock.
Throttle
Enforces a minimum gap between outbound requests.

Constants§

MIN_INTERVAL
The smallest gap allowed between two outbound requests.

Traits§

Timer
Wall-clock time, and the ability to wait for some of it.