Show rate limit notices (#15515)
This UI change is behind a `ZedPro` feature flag so that it won't be visible until we're ready to launch that service. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
8c54a46202
commit
9751e61101
6 changed files with 160 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{db::UserId, executor::Executor, Database, Error, Result};
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use dashmap::{DashMap, DashSet};
|
||||
use rpc::ErrorCodeExt;
|
||||
use sea_orm::prelude::DateTimeUtc;
|
||||
use std::sync::Arc;
|
||||
use util::ResultExt;
|
||||
|
@ -73,7 +73,9 @@ impl RateLimiter {
|
|||
self.dirty_buckets.insert(bucket_key);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!("rate limit exceeded"))?
|
||||
Err(rpc::proto::ErrorCode::RateLimitExceeded
|
||||
.message("rate limit exceeded".into())
|
||||
.anyhow())?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,7 @@ impl RateLimiter {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct RateBucket {
|
||||
capacity: usize,
|
||||
token_count: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue