feat(db): add db cluster logic and tests#338
Conversation
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Test Results337 tests 337 ✅ 20m 29s ⏱️ Results for commit 0f68992. ♻️ This comment has been updated with latest results. |
Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Benchmark Results |
| client_handler: Arc<ClientHandler>, | ||
| task_manager: Arc<TaskManager>, | ||
| config: ServerConfig, | ||
| cluster: Option<ClusterRuntime>, |
There was a problem hiding this comment.
ClusterRuntime would ideally always contain store_handler.... and we typically only ever want to access store_handler directly independent of cluster if cluster doesn't exist? Seems like we should have a cleaner
enum StoreRuntime {
Standalone(StoreHandler), // perhaps a more befitting rename to handler/ runtime to be consistent
Cluster(ClusterRuntime),
}There was a problem hiding this comment.
Actually agree with this, I went in the direction of not changing the shape of Server, but this is the better direction long term
| } | ||
|
|
||
| pub(crate) async fn list_stores_response( | ||
| cluster: Option<&ClusterRuntime>, |
There was a problem hiding this comment.
Not particularly sold on having optional cluster and a reference to store_handler when cluster always contains handler... see above comment
There was a problem hiding this comment.
A'firm, I will change the shape now
|
|
||
| fn task_manager(&self) -> Arc<TaskManager>; | ||
|
|
||
| fn should_spawn_persistence(&self) -> bool { |
There was a problem hiding this comment.
FIXME on this so we don't forget while implementing AI db cluster logic
…odes Signed-off-by: Jim Ezesinachi <ezesinachijim@gmail.com>
|
|
||
| fn apply(&mut self, data: &DbCommand) -> Result<DbResponse, StorageError<u64>> { | ||
| match data { | ||
| DbCommand::CreateStore(payload) => { |
There was a problem hiding this comment.
There's probably a nice way to turn decode_payload into a macro so we dont have to manually pass that string but can extract it from the ty via stringify!
There was a problem hiding this comment.
Something like
macro_rules! decode_payload {
($ty:ty, $payload:expr) => {{
<$ty>::decode($payload).map_err(|err| StorageError::IO {
source: StorageIOError::read_state_machine(&std::io::Error::other(format!(
"failed to decode {} raft payload: {}",
stringify!($ty),
err,
))),
})
}};
}
let params: query::CreateStore =
decode_payload!(query::CreateStore, payload)?;| use std::any::{Any, TypeId}; | ||
|
|
||
| pub(crate) fn map_client_write_error( | ||
| command_name: &str, |
There was a problem hiding this comment.
Another good use of macros to enforce not needing command name alongside the actual command
| prost.workspace = true | ||
| openraft.workspace = true | ||
| ahnlich-replication = { path = "../replication", version = "*" } | ||
| bitcode = { version = "0.6", features = ["serde"] } |
There was a problem hiding this comment.
We should move to general Cargo.toml... my suspicion is we will reuse elsewhere
No description provided.