fix(redis): paginate stream entries

This commit is contained in:
onenewcode authored and GitHub committed 2026-07-30 15:56:56 +08:00
1 parent 7775bbf8f8
commit 223e9b3a2f
21 files changed
+479 -33

No files matched your search

+1
View File
@@ -493,6 +493,7 @@ 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-entries", post(routes::redis::get_stream_entries))
.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))
+25
View File
@@ -76,6 +76,15 @@ pub struct RedisKeyRequest {
pub key_raw: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisStreamEntriesRequest {
pub connection_id: String,
pub db: u32,
pub key_raw: String,
pub cursor: Option<String>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisStreamGroupRequest {
@@ -322,6 +331,22 @@ 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_entries(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisStreamEntriesRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let result = dbx_core::redis_ops::redis_stream_entries_in_db_core(
&state.app,
&req.connection_id,
req.db,
&req.key_raw,
req.cursor.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 get_stream_groups(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisKeyRequest>,