Skip to content

Commit ab67fa4

Browse files
authored
Merge pull request #122 from mateusfreira/fix-parsing-db-cration
Minor fix db creation
2 parents 647ba08 + 9cc217f commit ab67fa4

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/lib/bo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl From<i32> for ConsensuStrategy {
245245

246246
impl From<String> for ConsensuStrategy {
247247
fn from(val: String) -> Self {
248-
log::debug!("Val in ConsensuStrategy {}", val);
248+
log::debug!("Val in ConsensuStrategy {}.", val);
249249
use self::ConsensuStrategy::*;
250250
match val.as_str() {
251251
"arbiter" => Arbiter,

src/lib/db_ops.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pub fn create_db(
1717
strategy: ConsensuStrategy,
1818
) -> Response {
1919
if dbs.is_primary() || client.is_primary() {
20+
log::debug!(
21+
"Request::CreateDb - Creating database {} with strategy {:?}",
22+
name,
23+
strategy
24+
);
2025
// If this node is the primary or the primary is asking to create it
2126
let empty_db_box = create_temp_db(name.clone(), strategy, dbs);
2227
let empty_db = Arc::try_unwrap(empty_db_box);

src/lib/parse_request.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Request {
5858
PARSER_HASH_TABLE.keys().map(|x| x.to_string()).collect()
5959
}
6060
pub fn parse(input: &str) -> Result<Request, String> {
61-
let mut command = input.splitn(3, " ");
61+
let mut command = input.trim_end_matches(';').splitn(3, " ");
6262
match command.next() {
6363
Some("") | None => {
6464
log::debug!("empty command");
@@ -661,7 +661,10 @@ fn parse_create_db_command(command: &mut std::str::SplitN<&str>) -> Result<Reque
661661
}
662662
};
663663
let mut rest = match command.next() {
664-
Some(rest) => rest.splitn(2, " "),
664+
Some(rest) => {
665+
log::debug!("CreateDb rest command {}", rest);
666+
rest.splitn(2, " ")
667+
},
665668
None => {
666669
log::debug!("create-db needs token and strategy");
667670
return Err(String::from("create-db must be followed by a token"));

src/lib/replication_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub fn replicate_request(
285285
token,
286286
strategy,
287287
} => {
288-
log::debug!("Will replicate command a created database name {}", name);
288+
log::debug!("Will replicate command a created database name {}, {}", name, strategy.to_string());
289289
replicate_web(
290290
replication_sender,
291291
format!("create-db {} {} {}", name, token, strategy.to_string()),

0 commit comments

Comments
 (0)