Skip to content

Commit

Permalink
Replace super imports with crate
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan770 committed Jan 4, 2021
1 parent 4d7bc95 commit 6948c27
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 36 deletions.
8 changes: 5 additions & 3 deletions spartan/http/routing.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// use crate::{config::Config, http::middleware::access::Access};
use std::{convert::Infallible, sync::Arc};

use warp::{any, body::json, delete, get, path, post, wrap_fn, Filter, Rejection, Reply};

use super::middleware::access::{access, AccessError};
use crate::{actions::ResponseError, node::Manager};
use crate::{
actions::ResponseError,
http::middleware::access::{access, AccessError},
node::Manager,
};

macro_rules! route {
($name:ident) => {
Expand Down
3 changes: 1 addition & 2 deletions spartan/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use thiserror::Error;
use tokio::signal::ctrl_c;
use warp::{serve, Error};

use super::routing::attach_routes;
use crate::node::Manager;
use crate::{http::routing::attach_routes, node::Manager};

#[derive(Error, Debug)]
pub enum ServerError {
Expand Down
18 changes: 9 additions & 9 deletions spartan/node/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use futures_util::{stream::iter, StreamExt, TryStreamExt};
use thiserror::Error;
use warp::hyper::StatusCode;

use super::{
event::Event,
persistence::{
log::Log,
snapshot::{PersistMode, Snapshot},
PersistenceError,
},
Node, DB,
};
use crate::{
actions::RespondableError,
config::{persistence::Persistence, Config},
node::{
event::Event,
persistence::{
log::Log,
snapshot::{PersistMode, Snapshot},
PersistenceError,
},
Node, DB,
},
};

#[derive(Error, Debug)]
Expand Down
3 changes: 1 addition & 2 deletions spartan/node/persistence/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ use tokio::{
io::{AsyncRead, AsyncReadExt, AsyncSeek, AsyncSeekExt, AsyncWriteExt},
};

use super::PersistenceError;
#[cfg(feature = "replication")]
use crate::node::persistence::snapshot::REPLICATION_FILE as SNAPSHOT_REPLICATION_FILE;
use crate::{
config::persistence::PersistenceConfig,
node::{
event::{Event, EventLog},
persistence::snapshot::Snapshot,
persistence::{snapshot::Snapshot, PersistenceError},
Queue,
},
};
Expand Down
6 changes: 4 additions & 2 deletions spartan/node/persistence/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use cfg_if::cfg_if;
use serde::{de::DeserializeOwned, Serialize};
use tokio::fs::{create_dir, read, write};

use super::PersistenceError;
use crate::{config::persistence::PersistenceConfig, node::Queue};
use crate::{
config::persistence::PersistenceConfig,
node::{persistence::PersistenceError, Queue},
};

const QUEUE_FILE: &str = "queue";

Expand Down
2 changes: 1 addition & 1 deletion spartan/node/queue.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use tokio::sync::{Mutex, MutexGuard};

use super::{event::Event, persistence::PersistenceError, Manager};
#[cfg(feature = "replication")]
use crate::node::replication::storage::ReplicationStorage;
use crate::node::{event::Event, persistence::PersistenceError, Manager};

pub struct Queue<DB> {
/// Inner database
Expand Down
10 changes: 6 additions & 4 deletions spartan/node/replication/primary/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ use futures_util::{stream::iter, StreamExt, TryStreamExt};
use itertools::Itertools;
use tokio::io::{AsyncRead, AsyncWrite};

use super::{
error::{PrimaryError, PrimaryResult},
stream::Stream,
use crate::node::{
replication::primary::{
error::{PrimaryError, PrimaryResult},
stream::Stream,
},
Manager,
};
use crate::node::Manager;

pub struct RecvIndex<'s, T> {
stream: &'s mut Stream<T>,
Expand Down
12 changes: 7 additions & 5 deletions spartan/node/replication/primary/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ use tokio::{
};
use tokio_util::codec::{Decoder, Framed};

use super::{
error::{PrimaryError, PrimaryResult},
index::{BatchAskIndex, RecvIndex},
};
use crate::{
config::replication::Primary,
node::{
event::Event,
replication::message::{PrimaryRequest, ReplicaRequest, Request},
replication::{
message::{PrimaryRequest, ReplicaRequest, Request},
primary::{
error::{PrimaryError, PrimaryResult},
index::{BatchAskIndex, RecvIndex},
},
},
},
utils::codec::BincodeCodec,
};
Expand Down
3 changes: 1 addition & 2 deletions spartan/node/replication/replica/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use tokio::{
};
use tokio_util::codec::{Decoder, Framed};

use super::message::Request;
use crate::{
config::replication::Replica,
node::{
event::EventLog,
replication::message::{PrimaryRequest, ReplicaRequest},
replication::message::{PrimaryRequest, ReplicaRequest, Request},
Manager,
},
utils::codec::BincodeCodec,
Expand Down
4 changes: 3 additions & 1 deletion spartan/node/replication/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use serde::{Deserialize, Serialize};

use super::{primary::storage::PrimaryStorage, replica::storage::ReplicaStorage};
use crate::node::replication::{
primary::storage::PrimaryStorage, replica::storage::ReplicaStorage,
};

#[derive(Serialize, Deserialize)]
pub enum ReplicationStorage {
Expand Down
3 changes: 1 addition & 2 deletions spartan_lib/core/db/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use std::{

use serde::{de::DeserializeOwned, Deserialize, Serialize};

use super::StatusAwareDatabase;
use crate::core::{
db::Database,
db::{Database, StatusAwareDatabase},
payload::{Identifiable, Sortable, Status},
};

Expand Down
6 changes: 4 additions & 2 deletions spartan_lib/core/db/vec/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use serde::{Deserialize, Serialize};

use super::StatusAwareDatabase;
use crate::core::{db::Database, payload::Identifiable};
use crate::core::{
db::{Database, StatusAwareDatabase},
payload::Identifiable,
};

/// [`Vec`]-based database
///
Expand Down
2 changes: 1 addition & 1 deletion spartan_lib/core/payload/dispatchable.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::Identifiable;
use crate::core::payload::Identifiable;

/// Interface for working with dispatchable messages
pub trait Dispatchable: Identifiable {
Expand Down

0 comments on commit 6948c27

Please sign in to comment.