Created
March 29, 2022 23:54
-
-
Save jayhuang75/081e1509b5e512d8a464d25a90a630ef to your computer and use it in GitHub Desktop.
new_token_bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// TokeBucket implementation | |
| impl TokenBucket { | |
| pub fn new(rate: i64, max_token: i64) -> Self { | |
| TokenBucket { | |
| rate: rate, | |
| max_tokens: max_token, | |
| current_tokens: max_token, | |
| last_refill_timestamp: Utc::now(), | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment