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:
Max Brunsfeld 2024-07-31 12:05:19 -07:00 committed by GitHub
parent 8c54a46202
commit 9751e61101
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 160 additions and 22 deletions

View file

@ -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,