node: Move tracking store to `radicle` crate
This commit is contained in:
parent
cf80f246b3
commit
cf8113765c
|
|
@ -39,7 +39,6 @@ thiserror = { version = "1" }
|
||||||
[dependencies.radicle]
|
[dependencies.radicle]
|
||||||
path = "../radicle"
|
path = "../radicle"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
features = ["sql"]
|
|
||||||
|
|
||||||
[dependencies.radicle-term]
|
[dependencies.radicle-term]
|
||||||
path = "../radicle-term"
|
path = "../radicle-term"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
mod store;
|
|
||||||
|
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
|
|
@ -13,11 +11,10 @@ use radicle::storage::{Namespaces, ReadRepository as _, ReadStorage};
|
||||||
use crate::prelude::Id;
|
use crate::prelude::Id;
|
||||||
use crate::service::NodeId;
|
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 crate::node::tracking::{Alias, Node, Policy, Repo, Scope};
|
||||||
|
|
||||||
pub use store::Config as Store;
|
|
||||||
pub use store::Error;
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum NamespacesError {
|
pub enum NamespacesError {
|
||||||
#[error("Failed to find tracking policy for {rid}")]
|
#[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.
|
/// Default scope, if a scope for a specific repository was not found.
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
/// Underlying configuration store.
|
/// Underlying configuration store.
|
||||||
store: store::Config,
|
store: Store,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Create a new tracking configuration.
|
/// 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 {
|
Self {
|
||||||
policy,
|
policy,
|
||||||
scope,
|
scope,
|
||||||
|
|
@ -143,7 +140,7 @@ impl Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ops::Deref for Config {
|
impl ops::Deref for Config {
|
||||||
type Target = store::Config;
|
type Target = Store;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.store
|
&self.store
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ edition = "2021"
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
test = ["qcheck", "radicle-crypto/test"]
|
test = ["qcheck", "radicle-crypto/test"]
|
||||||
sql = ["sqlite"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
amplify = { version = "4.0.0-beta.7", default-features = false, features = ["std"] }
|
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"] }
|
serde_json = { version = "1", features = ["preserve_order"] }
|
||||||
siphasher = { version = "0.3.10" }
|
siphasher = { version = "0.3.10" }
|
||||||
radicle-git-ext = { version = "0", features = ["serde"] }
|
radicle-git-ext = { version = "0", features = ["serde"] }
|
||||||
sqlite = { version = "0.30.3", optional = true }
|
sqlite = { version = "0.30.3" }
|
||||||
tempfile = { version = "3.3.0" }
|
tempfile = { version = "3.3.0" }
|
||||||
thiserror = { version = "1" }
|
thiserror = { version = "1" }
|
||||||
unicode-normalization = { version = "0.1" }
|
unicode-normalization = { version = "0.1" }
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ pub mod node;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
pub mod rad;
|
pub mod rad;
|
||||||
pub mod serde_ext;
|
pub mod serde_ext;
|
||||||
#[cfg(feature = "sql")]
|
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
pub mod storage;
|
pub mod storage;
|
||||||
#[cfg(any(test, feature = "test"))]
|
#[cfg(any(test, feature = "test"))]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
pub mod store;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
@ -56,7 +58,6 @@ impl FromStr for Policy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sql")]
|
|
||||||
impl sqlite::BindableWithIndex for Policy {
|
impl sqlite::BindableWithIndex for Policy {
|
||||||
fn bind<I: sqlite::ParameterIndex>(
|
fn bind<I: sqlite::ParameterIndex>(
|
||||||
self,
|
self,
|
||||||
|
|
@ -71,7 +72,6 @@ impl sqlite::BindableWithIndex for Policy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sql")]
|
|
||||||
impl TryFrom<&sqlite::Value> for Policy {
|
impl TryFrom<&sqlite::Value> for Policy {
|
||||||
type Error = sqlite::Error;
|
type Error = sqlite::Error;
|
||||||
|
|
||||||
|
|
@ -124,7 +124,6 @@ impl FromStr for Scope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sql")]
|
|
||||||
impl sqlite::BindableWithIndex for Scope {
|
impl sqlite::BindableWithIndex for Scope {
|
||||||
fn bind<I: sqlite::ParameterIndex>(
|
fn bind<I: sqlite::ParameterIndex>(
|
||||||
self,
|
self,
|
||||||
|
|
@ -139,7 +138,6 @@ impl sqlite::BindableWithIndex for Scope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sql")]
|
|
||||||
impl TryFrom<&sqlite::Value> for Scope {
|
impl TryFrom<&sqlite::Value> for Scope {
|
||||||
type Error = sqlite::Error;
|
type Error = sqlite::Error;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ use std::{fmt, io, ops::Not as _};
|
||||||
use sqlite as sql;
|
use sqlite as sql;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::prelude::Id;
|
use crate::prelude::{Id, NodeId};
|
||||||
use crate::service::NodeId;
|
|
||||||
|
|
||||||
use super::{Node, Policy, Repo, Scope};
|
use super::{Node, Policy, Repo, Scope};
|
||||||
|
|
||||||
|
|
@ -242,7 +241,7 @@ impl Config {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use radicle::assert_matches;
|
use crate::assert_matches;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::arbitrary;
|
use crate::test::arbitrary;
|
||||||
Loading…
Reference in New Issue