node: Move tracking store to `radicle` crate

This commit is contained in:
Alexis Sellier 2023-03-15 11:14:47 +01:00
parent cf80f246b3
commit cf8113765c
No known key found for this signature in database
7 changed files with 10 additions and 19 deletions

View File

@ -39,7 +39,6 @@ thiserror = { version = "1" }
[dependencies.radicle]
path = "../radicle"
version = "0.2.0"
features = ["sql"]
[dependencies.radicle-term]
path = "../radicle-term"

View File

@ -1,5 +1,3 @@
mod store;
use std::ops;
use log::{error, warn};
@ -13,11 +11,10 @@ use radicle::storage::{Namespaces, ReadRepository as _, ReadStorage};
use crate::prelude::Id;
use crate::service::NodeId;
pub use crate::node::tracking::store::Config as Store;
pub use crate::node::tracking::store::Error;
pub use crate::node::tracking::{Alias, Node, Policy, Repo, Scope};
pub use store::Config as Store;
pub use store::Error;
#[derive(Debug, Error)]
pub enum NamespacesError {
#[error("Failed to find tracking policy for {rid}")]
@ -52,12 +49,12 @@ pub struct Config {
/// Default scope, if a scope for a specific repository was not found.
scope: Scope,
/// Underlying configuration store.
store: store::Config,
store: Store,
}
impl Config {
/// Create a new tracking configuration.
pub fn new(policy: Policy, scope: Scope, store: store::Config) -> Self {
pub fn new(policy: Policy, scope: Scope, store: Store) -> Self {
Self {
policy,
scope,
@ -143,7 +140,7 @@ impl Config {
}
impl ops::Deref for Config {
type Target = store::Config;
type Target = Store;
fn deref(&self) -> &Self::Target {
&self.store

View File

@ -8,7 +8,6 @@ edition = "2021"
[features]
default = []
test = ["qcheck", "radicle-crypto/test"]
sql = ["sqlite"]
[dependencies]
amplify = { version = "4.0.0-beta.7", default-features = false, features = ["std"] }
@ -24,7 +23,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["preserve_order"] }
siphasher = { version = "0.3.10" }
radicle-git-ext = { version = "0", features = ["serde"] }
sqlite = { version = "0.30.3", optional = true }
sqlite = { version = "0.30.3" }
tempfile = { version = "3.3.0" }
thiserror = { version = "1" }
unicode-normalization = { version = "0.1" }

View File

@ -17,7 +17,6 @@ pub mod node;
pub mod profile;
pub mod rad;
pub mod serde_ext;
#[cfg(feature = "sql")]
pub mod sql;
pub mod storage;
#[cfg(any(test, feature = "test"))]

View File

@ -1,3 +1,5 @@
pub mod store;
use std::fmt;
use std::str::FromStr;
@ -56,7 +58,6 @@ impl FromStr for Policy {
}
}
#[cfg(feature = "sql")]
impl sqlite::BindableWithIndex for Policy {
fn bind<I: sqlite::ParameterIndex>(
self,
@ -71,7 +72,6 @@ impl sqlite::BindableWithIndex for Policy {
}
}
#[cfg(feature = "sql")]
impl TryFrom<&sqlite::Value> for Policy {
type Error = sqlite::Error;
@ -124,7 +124,6 @@ impl FromStr for Scope {
}
}
#[cfg(feature = "sql")]
impl sqlite::BindableWithIndex for Scope {
fn bind<I: sqlite::ParameterIndex>(
self,
@ -139,7 +138,6 @@ impl sqlite::BindableWithIndex for Scope {
}
}
#[cfg(feature = "sql")]
impl TryFrom<&sqlite::Value> for Scope {
type Error = sqlite::Error;

View File

@ -5,8 +5,7 @@ use std::{fmt, io, ops::Not as _};
use sqlite as sql;
use thiserror::Error;
use crate::prelude::Id;
use crate::service::NodeId;
use crate::prelude::{Id, NodeId};
use super::{Node, Policy, Repo, Scope};
@ -242,7 +241,7 @@ impl Config {
#[cfg(test)]
mod test {
use radicle::assert_matches;
use crate::assert_matches;
use super::*;
use crate::test::arbitrary;