Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 150 additions & 3 deletions apps/tauri/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ rust_decimal = { version = "1", features = ["serde"] }
ipnetwork = "0.20"
mac_address = "1.1"
bit-vec = "0.6.3"
redis = { version = "0.27", features = ["aio", "tokio-comp"] }

[profile.release]
codegen-units = 1
Expand Down
68 changes: 66 additions & 2 deletions apps/tauri/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::connection::{
ConnectionConfig, ConnectionError, ConnectionId, ConnectionManager, ConnectionRegistry,
ErdSchema, PostgresObjectDetail, SchemaObject, SchemaObjectKind, SqlObjectKind, SqlObjectNode,
SqliteOverview, TableSchema,
ErdSchema, PostgresObjectDetail, RedisScanPage, SchemaObject, SchemaObjectKind, SqlObjectKind,
SqlObjectNode, SqliteOverview, TableSchema,
};
use crate::profiles::{ConnectionProfile, ProfileStore, ProfileStoreError};
use crate::secrets::SharedSecretStore;
Expand Down Expand Up @@ -76,6 +76,70 @@ pub fn db_connect_mysql(
})
}

#[tauri::command]
pub fn db_connect_redis(
host: String,
port: u16,
password: Option<String>,
username: Option<String>,
db: Option<u8>,
id: Option<String>,
registry: State<'_, ConnectionRegistry>,
) -> Result<ConnectionId, ConnectionError> {
registry.connect(ConnectionConfig::Redis {
host,
port,
password,
username,
db,
id,
})
}

#[tauri::command]
pub fn redis_ping(
id: ConnectionId,
registry: State<'_, ConnectionRegistry>,
) -> Result<String, ConnectionError> {
registry.with_redis(&id, |s| s.ping())
}

#[tauri::command]
pub fn redis_scan(
id: ConnectionId,
cursor: Option<u64>,
pattern: Option<String>,
count: Option<u32>,
registry: State<'_, ConnectionRegistry>,
) -> Result<RedisScanPage, ConnectionError> {
registry.with_redis(&id, |s| {
s.scan(
cursor.unwrap_or(0),
pattern.as_deref(),
count.map(|n| n as usize),
)
})
}

#[tauri::command]
pub fn redis_get(
id: ConnectionId,
key: String,
registry: State<'_, ConnectionRegistry>,
) -> Result<Option<String>, ConnectionError> {
registry.with_redis(&id, |s| s.get(&key))
}

#[tauri::command]
pub fn redis_set(
id: ConnectionId,
key: String,
value: String,
registry: State<'_, ConnectionRegistry>,
) -> Result<(), ConnectionError> {
registry.with_redis(&id, |s| s.set(&key, &value))
}

#[tauri::command]
pub fn profiles_list(
store: State<'_, ProfileStore>,
Expand Down
Loading
Loading