feat(redis): add stream consumer group monitoring

This commit is contained in:
onenewcode authored and GitHub committed 2026-07-28 23:16:39 +08:00
1 parent 99cfa1b516
commit 31f0b7d6ef
23 files changed
+2092 -44

No files matched your search

+3
View File
@@ -466,6 +466,9 @@ async fn main() {
.route("/redis/scan-keys-batch", post(routes::redis::scan_keys_batch))
.route("/redis/scan-values", post(routes::redis::scan_values))
.route("/redis/get-value", post(routes::redis::get_value))
.route("/redis/get-stream-groups", post(routes::redis::get_stream_groups))
.route("/redis/get-stream-consumers", post(routes::redis::get_stream_consumers))
.route("/redis/get-stream-pending", post(routes::redis::get_stream_pending))
.route("/redis/load-more", post(routes::redis::load_more))
.route("/redis/set-string", post(routes::redis::set_string))
.route("/redis/delete-key", post(routes::redis::delete_key))
+65
View File
@@ -76,6 +76,26 @@ pub struct RedisKeyRequest {
pub key_raw: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisStreamGroupRequest {
pub connection_id: String,
pub db: u32,
pub key_raw: String,
pub group_raw: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisStreamPendingRequest {
pub connection_id: String,
pub db: u32,
pub key_raw: String,
pub group_raw: String,
pub cursor: Option<String>,
pub consumer_raw: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisLoadMoreRequest {
@@ -302,6 +322,51 @@ pub async fn get_value(
Ok(Json(serde_json::to_value(result).map_err(|e| AppError::from(e.to_string()))?))
}
pub async fn get_stream_groups(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisKeyRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let result =
dbx_core::redis_ops::redis_stream_groups_in_db_core(&state.app, &req.connection_id, req.db, &req.key_raw)
.await
.map_err(AppError::from)?;
Ok(Json(serde_json::to_value(result).map_err(|e| AppError::from(e.to_string()))?))
}
pub async fn get_stream_consumers(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisStreamGroupRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let result = dbx_core::redis_ops::redis_stream_consumers_in_db_core(
&state.app,
&req.connection_id,
req.db,
&req.key_raw,
&req.group_raw,
)
.await
.map_err(AppError::from)?;
Ok(Json(serde_json::to_value(result).map_err(|e| AppError::from(e.to_string()))?))
}
pub async fn get_stream_pending(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisStreamPendingRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let result = dbx_core::redis_ops::redis_stream_pending_in_db_core(
&state.app,
&req.connection_id,
req.db,
&req.key_raw,
&req.group_raw,
req.cursor.as_deref(),
req.consumer_raw.as_deref(),
)
.await
.map_err(AppError::from)?;
Ok(Json(serde_json::to_value(result).map_err(|e| AppError::from(e.to_string()))?))
}
pub async fn load_more(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisLoadMoreRequest>,