Skip to content

Commit

Permalink
doc: add limiter description
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuoTiJia committed Sep 11, 2023
1 parent 82accfb commit 7209c53
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions meta/src/limiter/mod.rs
Expand Up @@ -15,6 +15,31 @@ pub use local_request_limiter::LocalRequestLimiter;
pub use none_limiter::NoneLimiter;

pub type LimiterRef = Arc<dyn RequestLimiter>;

/// The distributed current limiter is divided into two parts.
/// There is a cached LocalBucket on the data node,
/// and a RateBucket on the meta node.
///
/// When a request comes,
/// the token bucket on the data node is first accessed.
/// If the token bucket in the data cache has enough tokens, the request can pass.
/// If the token bucket in the data cache is not enough,
/// the greedy method is used to request tokens from the Meta's RateBucket.
///
/// When the current limiter configuration changes,
/// the local LocalBucket is changed through the watch mechanism.
// │ x
// │
// │ x
// │ ┌────────────────────┐
// │ ┌────────────────┐ │ │
// │ require local │ │ require remote │ x x │
// │ 6 x │ ├─────────────────►│ x │
// ├────────────────►│ x x x │ │ │
// │ │ │ │ x x x │
// │ └────────────────┘ │ │
// │ └────────────────────┘
///
#[async_trait]
pub trait RequestLimiter: Send + Sync + Debug {
async fn check_coord_data_in(&self, data_len: usize) -> MetaResult<()>;
Expand Down

0 comments on commit 7209c53

Please sign in to comment.