наблюдаемость: завершить базовый контур Community
Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
This commit is contained in:
@@ -74,6 +74,12 @@ pub struct RateLimitBucketState {
|
||||
pub last_refill_unix_ms: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum RateLimitDecision {
|
||||
Allowed,
|
||||
Rejected { retry_after_ms: u64 },
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ReplayGuardStatus {
|
||||
@@ -86,6 +92,12 @@ pub struct CoordinationStateValue {
|
||||
pub payload: Value,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum CoordinationStateReservation {
|
||||
Reserved,
|
||||
Existing(CoordinationStateValue),
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait ResponseCacheStore: Send + Sync {
|
||||
async fn get(&self, key: &str) -> Result<Option<CachedResponse>, CacheStoreError>;
|
||||
@@ -108,6 +120,14 @@ pub trait RateLimitStateStore: Send + Sync {
|
||||
ttl: Duration,
|
||||
) -> Result<(), CacheStoreError>;
|
||||
async fn delete_bucket(&self, key: &str) -> Result<(), CacheStoreError>;
|
||||
async fn consume_token(
|
||||
&self,
|
||||
key: &str,
|
||||
burst_tokens_micros: u64,
|
||||
refill_per_second_micros: u64,
|
||||
now_unix_ms: i64,
|
||||
ttl: Duration,
|
||||
) -> Result<RateLimitDecision, CacheStoreError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -135,6 +155,26 @@ pub trait CoordinationStateStore: Send + Sync {
|
||||
ttl: Duration,
|
||||
) -> Result<(), CacheStoreError>;
|
||||
async fn delete_value(&self, scope: CacheScope, key: &str) -> Result<(), CacheStoreError>;
|
||||
async fn take_value(
|
||||
&self,
|
||||
scope: CacheScope,
|
||||
key: &str,
|
||||
) -> Result<Option<CoordinationStateValue>, CacheStoreError>;
|
||||
async fn reserve_value(
|
||||
&self,
|
||||
scope: CacheScope,
|
||||
key: &str,
|
||||
value: CoordinationStateValue,
|
||||
ttl: Duration,
|
||||
) -> Result<CoordinationStateReservation, CacheStoreError>;
|
||||
async fn compare_and_set_value(
|
||||
&self,
|
||||
scope: CacheScope,
|
||||
key: &str,
|
||||
expected: &CoordinationStateValue,
|
||||
value: CoordinationStateValue,
|
||||
ttl: Duration,
|
||||
) -> Result<bool, CacheStoreError>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Error, PartialEq, Eq)]
|
||||
|
||||
@@ -66,8 +66,9 @@ pub mod domain {
|
||||
|
||||
pub mod ports {
|
||||
pub use crate::cache::{
|
||||
CacheStoreError, CoordinationStateStore, CoordinationStateValue, RateLimitStateStore,
|
||||
ReplayGuardStatus, ReplayGuardStore, ResponseCacheStore,
|
||||
CacheStoreError, CoordinationStateReservation, CoordinationStateStore,
|
||||
CoordinationStateValue, RateLimitDecision, RateLimitStateStore, ReplayGuardStatus,
|
||||
ReplayGuardStore, ResponseCacheStore,
|
||||
};
|
||||
pub use crate::ext::access::{
|
||||
OwnerOnlyPolicyEngine, PolicyAction, PolicyDecision, PolicyEngine, PolicyScope,
|
||||
@@ -108,8 +109,9 @@ pub use auth::{
|
||||
};
|
||||
pub use cache::{
|
||||
CacheBackend, CacheScope, CacheStoreError, CachedHeader, CachedResponse,
|
||||
CoordinationStateStore, CoordinationStateValue, ParseCacheBackendError, RateLimitBucketState,
|
||||
RateLimitStateStore, ReplayGuardStatus, ReplayGuardStore, ResponseCacheStore,
|
||||
CoordinationStateReservation, CoordinationStateStore, CoordinationStateValue,
|
||||
ParseCacheBackendError, RateLimitBucketState, RateLimitDecision, RateLimitStateStore,
|
||||
ReplayGuardStatus, ReplayGuardStore, ResponseCacheStore,
|
||||
};
|
||||
pub use edition::{
|
||||
EditionCapabilities, EditionLimits, MachineAccessMode, OperationSecurityLevel, ProductEdition,
|
||||
|
||||
Reference in New Issue
Block a user