-
Notifications
You must be signed in to change notification settings - Fork 33
feat(conf): support configuring DB storage directory #243
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
Changes from all commits
4642b03
70d4f76
bc86a5b
3dbe348
95ce678
069db6b
ca702d7
f0b6219
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,9 @@ impl ServerFactory { | |
| } | ||
| }, | ||
| #[cfg(unix)] | ||
| "unix" => Some(Box::new(unix::UnixServer::new(addr))), | ||
| "unix" => unix::UnixServer::new(addr, None) | ||
| .ok() | ||
| .map(|s| Box::new(s) as Box<dyn ServerTrait>), | ||
| #[cfg(not(unix))] | ||
|
Comment on lines
68
to
72
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. The |
||
| "unix" => None, | ||
| _ => None, | ||
|
|
@@ -77,13 +79,16 @@ impl ServerFactory { | |
| pub fn create_legacy_server( | ||
| protocol: &str, | ||
| addr: Option<String>, | ||
| db_dir: Option<&str>, | ||
| ) -> Option<Box<dyn ServerTrait>> { | ||
| match protocol.to_lowercase().as_str() { | ||
| "tcp" => TcpServer::new(addr) | ||
| "tcp" => TcpServer::new(addr, db_dir) | ||
| .ok() | ||
| .map(|s| Box::new(s) as Box<dyn ServerTrait>), | ||
| #[cfg(unix)] | ||
| "unix" => Some(Box::new(unix::UnixServer::new(addr))), | ||
| "unix" => unix::UnixServer::new(addr, db_dir) | ||
| .ok() | ||
| .map(|s| Box::new(s) as Box<dyn ServerTrait>), | ||
| #[cfg(not(unix))] | ||
| "unix" => None, | ||
| _ => None, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,22 +33,22 @@ pub struct UnixServer { | |
| } | ||
|
|
||
| impl UnixServer { | ||
| pub fn new(path: Option<String>) -> Self { | ||
| pub fn new(path: Option<String>, db_dir: Option<&str>) -> Result<Self, Box<dyn Error>> { | ||
| let path = path.unwrap_or_else(|| "/tmp/kiwidb.sock".to_string()); | ||
| let storage_options = Arc::new(StorageOptions::default()); | ||
| let db_path = PathBuf::from("./db"); | ||
| let db_path = PathBuf::from(db_dir.unwrap_or("./db")); | ||
| let mut storage = Storage::new(1, 0); | ||
| storage | ||
| .open(storage_options, db_path) | ||
| .expect("failed to open storage"); | ||
| .map_err(|e| Box::new(e) as Box<dyn Error>)?; | ||
| let executor = Arc::new(CmdExecutorBuilder::new().build()); | ||
|
Comment on lines
38
to
44
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in the same change — |
||
|
|
||
| Self { | ||
| Ok(Self { | ||
| path, | ||
| storage: Arc::new(storage), | ||
| cmd_table: Arc::new(create_command_table()), | ||
| executor, | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.