throttle_my_fn
: A Rust attribute macro to throttle the execution of functionsthrottle_my_fn
is a Rust attribute macro to limit a function's number of runs over a
specified period of time.
Add the dependency to your Cargo.toml
:
toml
[dependencies]
throttle_my_fn = "0.1"
Or, using cargo add
:
sh
$ cargo add throttle_my_fn
Include the macro:
rust
use throttle_my_fn::throttle;
Annotate the functions you want to throttle:
```rust
pub(crate) fn run10timespersecond(arg: &str) -> String { ... }
pub(crate) fn runonceper100milliseconds(arg: &str) -> String { ... } ```