Skip to content

Commit

Permalink
treewide: Apply clippy changes
Browse files Browse the repository at this point in the history
Clippy complained, and I let it fix up the code.
  • Loading branch information
jasobrown-rs committed Apr 16, 2024
1 parent f5a908b commit d4d2d7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Config {

pub fn read_config_file(path: &str) -> Result<String, std::io::Error> {
let mut file =
File::open(path).expect(format!("Failed to open config file at path {}", path).as_str());
File::open(path).unwrap_or_else(|_| panic!("Failed to open config file at path {}", path));
let mut contents = String::new();
file.read_to_string(&mut contents)?;
Ok(contents)
Expand Down
21 changes: 14 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ fn main() {
let args = Args::parse();
let config_file = read_config_file(&args.config).expect("Failed to read config file");
let config = config::parse_config_file(&config_file).expect("Failed to parse config file");
let file = match OpenOptions::new().read(true).write(true).create(true).open(
config
.clone()
.lock_file
.unwrap_or("/tmp/readyset_scheduler.lock".to_string()),
) {
let file = match OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(true)
.open(
config
.clone()
.lock_file
.unwrap_or("/tmp/readyset_scheduler.lock".to_string()),
) {
Ok(file) => file,
Err(err) => {
messages::print_error(
Expand Down Expand Up @@ -133,7 +138,9 @@ fn main() {
match supported {
Ok(true) => {
messages::print_info(
format!("Query is supported, adding it to proxysql and readyset").as_str(),
"Query is supported, adding it to proxysql and readyset"
.to_string()
.as_str(),
);
queries_added_or_change = true;
queries::cache_query(&mut readyset_conn, &digest_text)
Expand Down
6 changes: 3 additions & 3 deletions src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ pub fn find_queries_to_cache(
rows
}

pub fn replace_placeholders(query: &String) -> String {
pub fn replace_placeholders(query: &str) -> String {
// date placeholder
let query = query.replace("?-?-?", "?");
query

query.replace("?-?-?", "?")
}

pub fn check_readyset_query_support(
Expand Down
5 changes: 2 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ pub fn change_server_status(
config.readyset_host,
config.readyset_port,
status.unwrap(),
server_status.to_string()
server_status
)
.as_str(),
);
ps_conn.query_drop(format!(
"UPDATE mysql_servers SET status = '{}' {}",
server_status.to_string(),
where_clause
server_status, where_clause
))?;
ps_conn.query_drop("LOAD MYSQL SERVERS TO RUNTIME")?;
ps_conn.query_drop("SAVE MYSQL SERVERS TO DISK")?;
Expand Down

0 comments on commit d4d2d7c

Please sign in to comment.