наблюдаемость: завершить базовый контур Community
CI / Rust Checks (push) Failing after 4m28s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Community Image Smoke (push) Has been skipped
CI / Deploy (push) Has been skipped

Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
This commit is contained in:
2026-07-31 01:01:14 +03:00
parent 99bd05c145
commit 0e8f1ca03a
160 changed files with 13506 additions and 1499 deletions
+1
View File
@@ -3,6 +3,7 @@ name = "crank-core"
edition.workspace = true
license.workspace = true
rust-version.workspace = true
publish.workspace = true
version.workspace = true
[dependencies]
+40
View File
@@ -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)]
+6 -4
View File
@@ -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,