-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: explorer add stream view (#17)
* update: stream example * feat: stream view
- Loading branch information
Showing
11 changed files
with
572 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#[path = "common/lib.rs"] | ||
mod common; | ||
use crate::common::client::dead_pool; | ||
use anyhow::Result; | ||
use itertools::Itertools; | ||
use redis::{Cmd, Value}; | ||
use ratisui::utils::bytes_to_string; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let pool = dead_pool()?; | ||
let mut connection = pool.get().await?; | ||
let cmd = str_cmd!("xrevrange stream + -"); | ||
let x: Vec<(Vec<String>, Vec<Vec<String>>)> = cmd.query_async(&mut connection).await?; | ||
let x: Value = cmd.query_async(&mut connection).await?; | ||
println!("{:?}", x); | ||
|
||
let value = Value::BulkString("".as_bytes().to_vec()); | ||
|
||
if let Value::BulkString(bulk_string) = value { | ||
let bulk_string = bytes_to_string(bulk_string.clone()).unwrap_or_else(|e| e.to_string()); | ||
let bulk_string = bulk_string.replace("\t", "\\t"); | ||
// let bulk_string = format!("\"{}\"", bulk_string); | ||
let lines = bulk_string.lines(); | ||
let format = |str: &str| { | ||
format!("{str}") | ||
}; | ||
let vec = lines.map(|line| { | ||
format(line) | ||
}).collect_vec(); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.