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

refactor: split config into multiple modules #676

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion crates/benchmark/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tokio::{
time::{Duration, Instant},
};
use tracing::debug;
use utils::config::ClientConfig;
use utils::config::client::ClientConfig;
use xline_client::{types::kv::PutRequest, ClientOptions};

use crate::{args::Commands, bench_client::BenchClient, Benchmark};
Expand Down
4 changes: 2 additions & 2 deletions crates/curp-test-utils/src/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::{sync::mpsc, time::sleep};
use tracing::debug;
use utils::config::EngineConfig;
use utils::config::engine::EngineConfig;

use crate::{META_TABLE, REVISION_TABLE, TEST_TABLE};

Expand Down Expand Up @@ -422,7 +422,7 @@ impl TestCE {
after_sync_sender: mpsc::UnboundedSender<(TestCommand, LogIndex)>,
engine_cfg: EngineConfig,
) -> Self {
let engine_type = match engine_cfg {
let engine_type: EngineType = match engine_cfg {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: please remove this EngineType.

EngineConfig::Memory => EngineType::Memory,
EngineConfig::RocksDB(path) => EngineType::Rocks(path),
_ => unreachable!("Not supported storage type"),
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tonic::transport::ClientTlsConfig;
use tracing::debug;
#[cfg(madsim)]
use utils::ClientTlsConfig;
use utils::{build_endpoint, config::ClientConfig};
use utils::{build_endpoint, config::client::ClientConfig};

use self::{
retry::{Retry, RetryConfig},
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/server/cmd_worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ mod tests {
use test_macros::abort_on_panic;
use tokio::{sync::mpsc, time::Instant};
use tracing_test::traced_test;
use utils::config::EngineConfig;
use utils::config::engine::EngineConfig;

use super::*;
use crate::{log_entry::LogEntry, rpc::ProposeId};
Expand Down
8 changes: 5 additions & 3 deletions crates/curp/src/server/curp_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ use tracing::{debug, error, info, trace, warn};
#[cfg(madsim)]
use utils::ClientTlsConfig;
use utils::{
config::CurpConfig,
config::curp::CurpConfig,
task_manager::{tasks::TaskName, Listener, State, TaskManager},
};

use super::{
cmd_board::{CmdBoardRef, CommandBoard},
cmd_worker::{conflict_checked_mpmc, start_cmd_workers},
conflict::spec_pool_new::{SpObject, SpeculativePool},
conflict::uncommitted_pool::{UcpObject, UncommittedPool},
conflict::{
spec_pool_new::{SpObject, SpeculativePool},
uncommitted_pool::{UcpObject, UncommittedPool},
},
gc::gc_cmd_board,
lease_manager::LeaseManager,
raw_curp::{AppendEntries, RawCurp, Vote},
Expand Down
8 changes: 5 additions & 3 deletions crates/curp/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ use tonic::transport::ClientTlsConfig;
use tracing::instrument;
#[cfg(madsim)]
use utils::ClientTlsConfig;
use utils::{config::CurpConfig, task_manager::TaskManager, tracing::Extract};
use utils::{config::curp::CurpConfig, task_manager::TaskManager, tracing::Extract};

use self::curp_node::CurpNode;
pub use self::raw_curp::RawCurp;
pub use self::{conflict::spec_pool_new::SpObject, conflict::uncommitted_pool::UcpObject};
pub use self::{
conflict::{spec_pool_new::SpObject, uncommitted_pool::UcpObject},
raw_curp::RawCurp,
};
use crate::{
cmd::{Command, CommandExecutor},
members::{ClusterInfo, ServerId},
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/server/raw_curp/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ mod tests {
use std::{iter::repeat, ops::Index, sync::Arc};

use curp_test_utils::test_cmd::TestCommand;
use utils::config::{default_batch_max_size, default_log_entries_cap};
use utils::config::curp::{default_batch_max_size, default_log_entries_cap};

use super::*;

Expand Down
10 changes: 6 additions & 4 deletions crates/curp/src/server/raw_curp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use tracing::{
#[cfg(madsim)]
use utils::ClientTlsConfig;
use utils::{
config::CurpConfig,
config::curp::CurpConfig,
parking_lot_lock::{MutexMap, RwLockMap},
task_manager::TaskManager,
};
Expand All @@ -47,9 +47,11 @@ use self::{
state::{CandidateState, LeaderState, State},
};
use super::{
cmd_worker::CEEventTxApi, conflict::spec_pool_new::SpeculativePool,
conflict::uncommitted_pool::UncommittedPool, lease_manager::LeaseManagerRef,
storage::StorageApi, DB,
cmd_worker::CEEventTxApi,
conflict::{spec_pool_new::SpeculativePool, uncommitted_pool::UncommittedPool},
lease_manager::LeaseManagerRef,
storage::StorageApi,
DB,
};
use crate::{
cmd::Command,
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/server/raw_curp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::{
time::{sleep, Instant},
};
use tracing_test::traced_test;
use utils::config::{
use utils::config::curp::{
default_candidate_timeout_ticks, default_follower_timeout_ticks, default_heartbeat_interval,
CurpConfigBuilder,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/src/server/storage/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::marker::PhantomData;
use async_trait::async_trait;
use engine::{Engine, EngineType, StorageEngine, WriteOperation};
use prost::Message;
use utils::config::EngineConfig;
use utils::config::engine::EngineConfig;

use super::{StorageApi, StorageError};
use crate::{
Expand Down
5 changes: 4 additions & 1 deletion crates/curp/tests/it/common/curp_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ use tracing::debug;
use utils::{
build_endpoint,
config::{
default_quota, ClientConfig, CurpConfig, CurpConfigBuilder, EngineConfig, StorageConfig,
client::ClientConfig,
curp::{CurpConfig, CurpConfigBuilder},
engine::EngineConfig,
storage::{default_quota, StorageConfig},
},
task_manager::{tasks::TaskName, Listener, TaskManager},
};
Expand Down
2 changes: 1 addition & 1 deletion crates/curp/tests/it/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use curp_test_utils::{
use madsim::rand::{thread_rng, Rng};
use test_macros::abort_on_panic;
use tokio::net::TcpListener;
use utils::{config::ClientConfig, timestamp};
use utils::{config::client::ClientConfig, timestamp};

use crate::common::curp_group::{
commandpb::ProposeId, CurpGroup, FetchClusterRequest, ProposeRequest, ProposeResponse,
Expand Down
2 changes: 1 addition & 1 deletion crates/simulation/src/curp_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use parking_lot::Mutex;
use tokio::sync::mpsc;
use tracing::debug;
use utils::{
config::{ClientConfig, CurpConfigBuilder, EngineConfig},
config::{client::ClientConfig, curp::CurpConfigBuilder, engine::EngineConfig},
task_manager::TaskManager,
};

Expand Down
10 changes: 8 additions & 2 deletions crates/simulation/src/xline_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ use madsim::runtime::NodeHandle;
use tonic::transport::Channel;
use tracing::debug;
use utils::config::{
AuthConfig, ClientConfig, ClusterConfig, CompactConfig, CurpConfig, InitialClusterState,
ServerTimeout, StorageConfig, TlsConfig,
auth::AuthConfig,
client::ClientConfig,
cluster::{ClusterConfig, InitialClusterState},
compact::CompactConfig,
curp::CurpConfig,
server::ServerTimeout,
storage::StorageConfig,
tls::TlsConfig,
};
use xline::server::XlineServer;
use xline_client::{
Expand Down
Loading
Loading