Skip to content

Conversation

@geekbrother
Copy link
Collaborator

@geekbrother geekbrother commented Aug 28, 2025

Description

This PR updates the rate_limit crate with the following changes:

  • Updates deadpool_redis dependency to the latest 0.22;
  • Updates redis client to the latest 0.32;
  • Optimization in the token_bucket_many function by reusing the lua script instance instead of hashing it on every call;
  • Minor optimizations in the Lua token bucket script to cache the redis call, remove double calculation, and remove ipairs in a loop.

This PR fixes the Rust version in the CI fmt check job to use stable to be the same version as in the clippy job.

Formatting fixes for an updated Rust version to fix Clippy errors.

How Has This Been Tested?

Rate limiter unit tests were passed when tested on a local Redis instance.

Due Diligence

  • Breaking change
  • Requires a documentation update
  • Requires a e2e/integration test update

@geekbrother geekbrother self-assigned this Aug 28, 2025
@geekbrother geekbrother marked this pull request as ready for review August 28, 2025 20:17
Copilot AI review requested due to automatic review settings August 28, 2025 20:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the rate_limit crate with dependency upgrades and performance optimizations. The changes upgrade Redis-related dependencies to their latest versions and implement several optimizations to the token bucket rate limiting algorithm.

  • Updates deadpool_redis to 0.22 and redis to 0.32 for latest features and fixes
  • Optimizes token bucket operations by caching the Lua script instance and improving Redis call efficiency
  • Includes formatting fixes across multiple crates to address Rust toolchain updates

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/rate_limit/Cargo.toml Updates Redis dependencies to latest versions and adds once_cell for script caching
crates/rate_limit/src/lib.rs Implements script caching optimization and refactors function signatures
crates/rate_limit/src/token_bucket.lua Optimizes Lua script with cached Redis calls and improved loop handling
.github/workflows/ci.yaml Fixes CI formatting job to use stable Rust version
Multiple metrics files Formatting changes to consolidate import statements
crates/geoip/src/lib.rs Formatting changes and error handling improvements
crates/geoip/src/block.rs Minor optimization using is_some_and method
crates/analytics/tests/integration.rs Formatting changes to consolidate imports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@geekbrother geekbrother merged commit dfc1570 into main Sep 10, 2025
6 checks passed
@geekbrother geekbrother deleted the feat/update_rate_limiting_redis branch September 10, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants