Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix read only query builder #77

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parking_lot = { version = "0.12.3", default-features = false, features = ["deadl
redis = { version = "0.27.6", default-features = false, features = ["sentinel"] }
regex = { version = "1.11.1", default-features = false, features = ["std", "perf", "unicode-bool", "unicode-perl"] }
strum = { version = "0.26.3", default-features = false, features = ["std", "derive"] }
thiserror = "2.0.4"
thiserror = "2.0.6"
tokio = { version = "1.42.0", default-features = false, features = ["macros", "sync", "rt-multi-thread"], optional = true }
tracing = { version = "0.1.41", default-features = false, features = ["std", "attributes"], optional = true }

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Just add it to your `Cargo.toml`, like so:

```toml
falkordb = { version = "0.1.9" }
falkordb = { version = "0.1.10" }
```

### Run FalkorDB instance
Expand Down Expand Up @@ -69,7 +69,7 @@ This client supports nonblocking API using the [`tokio`](https://tokio.rs/) runt
It can be enabled like so:

```toml
falkordb = { version = "0.1.9", features = ["tokio"] }
falkordb = { version = "0.1.10", features = ["tokio"] }
```

Currently, this API requires running within a [
Expand Down Expand Up @@ -123,21 +123,21 @@ when using tokio: `"tokio-rustls"`/`"tokio-native-tls"`).
For Rustls:

```toml
falkordb = { version = "0.1.9", features = ["rustls"] }
falkordb = { version = "0.1.10", features = ["rustls"] }
```

```toml
falkordb = { version = "0.1.9", features = ["tokio-rustls"] }
falkordb = { version = "0.1.10", features = ["tokio-rustls"] }
```

For Native TLS:

```toml
falkordb = { version = "0.1.9", features = ["native-tls"] }
falkordb = { version = "0.1.10", features = ["native-tls"] }
```

```toml
falkordb = { version = "0.1.9", features = ["tokio-native-tls"] }
falkordb = { version = "0.1.10", features = ["tokio-native-tls"] }
```

### Tracing
Expand All @@ -146,7 +146,7 @@ This crate fully supports instrumentation using the [`tracing`](https://docs.rs/
it, simply, enable the `tracing` feature:

```toml
falkordb = { version = "0.1.9", features = ["tracing"] }
falkordb = { version = "0.1.10", features = ["tracing"] }
```

Note that different functions use different filtration levels, to avoid spamming your tests, be sure to enable the
Expand Down
7 changes: 4 additions & 3 deletions src/client/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ impl FalkorSyncClient {
})
}

/// Get the max number of connections in the client's connection pool

/// Get the max number of connections in the client's connection pool
pub fn connection_pool_size(&self) -> u8 {
self.inner.connection_pool_size
}
Expand All @@ -138,7 +139,7 @@ impl FalkorSyncClient {
///
/// # Arguments
/// * `config_Key`: A [`String`] representation of a configuration's key.
/// The config key can also be "*", which will return ALL the configuration options.
/// The config key can also be "*", which will return ALL the configuration options.
///
/// # Returns
/// A [`HashMap`] comprised of [`String`] keys, and [`ConfigValue`] values.
Expand All @@ -161,7 +162,7 @@ impl FalkorSyncClient {
///
/// # Arguments
/// * `config_Key`: A [`String`] representation of a configuration's key.
/// The config key can also be "*", which will return ALL the configuration options.
/// The config key can also be "*", which will return ALL the configuration options.
/// * `value`: The new value to set, which is anything that can be converted into a [`ConfigValue`], namely string types and i64.
#[cfg_attr(
feature = "tracing",
Expand Down
2 changes: 1 addition & 1 deletion src/graph/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl AsyncGraph {
&'a mut self,
query_string: &'a str,
) -> QueryBuilder<'a, QueryResult<LazyResultSet<'a>>, &'a str, Self> {
QueryBuilder::new(self, "GRAPH.QUERY_RO", query_string)
QueryBuilder::new(self, "GRAPH.RO_QUERY", query_string)
}

/// Creates a [`ProcedureQueryBuilder`] for this graph
Expand Down
2 changes: 1 addition & 1 deletion src/graph/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl SyncGraph {
&'a mut self,
query_string: &'a str,
) -> QueryBuilder<'a, QueryResult<LazyResultSet<'a>>, &'a str, Self> {
QueryBuilder::new(self, "GRAPH.QUERY_RO", query_string)
QueryBuilder::new(self, "GRAPH.RO_QUERY", query_string)
}

/// Creates a [`ProcedureQueryBuilder`] for this graph
Expand Down
17 changes: 9 additions & 8 deletions src/graph/query_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ impl<'a, Output, T: Display, G: HasGraphSchema> QueryBuilder<'a, Output, T, G> {
/// Specify a timeout after which to abort the query
///
/// # Arguments
/// * `timeout`: the timeout after which to abort, in ms
/// * `timeout`: the timeout after which the server is allowed to abort or throw this request,
/// in milliseconds, when that happens the server will return a timeout error
pub fn with_timeout(
self,
timeout: i64,
Expand Down Expand Up @@ -155,7 +156,7 @@ impl<'a, Output, T: Display, G: HasGraphSchema> QueryBuilder<'a, Output, T, G> {
}
}

impl<'a, Out, T: Display> QueryBuilder<'a, Out, T, SyncGraph> {
impl<Out, T: Display> QueryBuilder<'_, Out, T, SyncGraph> {
#[cfg_attr(
feature = "tracing",
tracing::instrument(name = "Common Query Execution Steps", skip_all, level = "trace")
Expand Down Expand Up @@ -234,7 +235,7 @@ impl<'a, T: Display> QueryBuilder<'a, QueryResult<LazyResultSet<'a>>, T, AsyncGr
}
}

impl<'a, T: Display> QueryBuilder<'a, ExecutionPlan, T, SyncGraph> {
impl<T: Display> QueryBuilder<'_, ExecutionPlan, T, SyncGraph> {
/// Executes the query, returning an [`ExecutionPlan`] from the data returned
pub fn execute(mut self) -> FalkorResult<ExecutionPlan> {
self.common_execute_steps().and_then(ExecutionPlan::parse)
Expand Down Expand Up @@ -386,7 +387,7 @@ impl<'a, Out, G: HasGraphSchema> ProcedureQueryBuilder<'a, Out, G> {
}
}

impl<'a, Out> ProcedureQueryBuilder<'a, Out, SyncGraph> {
impl<Out> ProcedureQueryBuilder<'_, Out, SyncGraph> {
#[cfg_attr(
feature = "tracing",
tracing::instrument(
Expand All @@ -397,7 +398,7 @@ impl<'a, Out> ProcedureQueryBuilder<'a, Out, SyncGraph> {
)]
fn common_execute_steps(&mut self) -> FalkorResult<redis::Value> {
let command = match self.readonly {
true => "GRAPH.QUERY_RO",
true => "GRAPH.RO_QUERY",
false => "GRAPH.QUERY",
};

Expand Down Expand Up @@ -431,7 +432,7 @@ impl<'a, Out> ProcedureQueryBuilder<'a, Out, AsyncGraph> {
)]
async fn common_execute_steps(&mut self) -> FalkorResult<redis::Value> {
let command = match self.readonly {
true => "GRAPH.QUERY_RO",
true => "GRAPH.RO_QUERY",
false => "GRAPH.QUERY",
};

Expand All @@ -453,7 +454,7 @@ impl<'a, Out> ProcedureQueryBuilder<'a, Out, AsyncGraph> {
}
}

impl<'a> ProcedureQueryBuilder<'a, QueryResult<Vec<FalkorIndex>>, SyncGraph> {
impl ProcedureQueryBuilder<'_, QueryResult<Vec<FalkorIndex>>, SyncGraph> {
/// Executes the procedure call and return a [`QueryResult`] type containing a result set of [`FalkorIndex`]s
/// This functions consumes self
#[cfg_attr(
Expand Down Expand Up @@ -481,7 +482,7 @@ impl<'a> ProcedureQueryBuilder<'a, QueryResult<Vec<FalkorIndex>>, AsyncGraph> {
}
}

impl<'a> ProcedureQueryBuilder<'a, QueryResult<Vec<Constraint>>, SyncGraph> {
impl ProcedureQueryBuilder<'_, QueryResult<Vec<Constraint>>, SyncGraph> {
/// Executes the procedure call and return a [`QueryResult`] type containing a result set of [`Constraint`]s
/// This functions consumes self
#[cfg_attr(
Expand Down
1 change: 0 additions & 1 deletion src/response/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ fn parse_string_array(
vector
.into_iter()
.map(FalkorValue::into_string)
.into_iter()
.collect::<Result<Vec<String>, FalkorDBError>>()
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/response/lazy_result_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> LazyResultSet<'a> {
}
}

impl<'a> Iterator for LazyResultSet<'a> {
impl Iterator for LazyResultSet<'_> {
type Item = Vec<FalkorValue>;

#[cfg_attr(
Expand Down
Loading