Skip to content
Merged
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
5 changes: 1 addition & 4 deletions server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ fn main() {
*config.git_mut().sha_kind_mut() = ShaKind::Short;

if let Err(e) = vergen(config) {
println!(
"cargo:warning=initializing vergen failed due to error: {}",
e
);
println!("cargo:warning=initializing vergen failed due to error: {e}",);
}

println!("cargo:rerun-if-changed=build.rs");
Expand Down
2 changes: 1 addition & 1 deletion server/src/alerts/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Target {
state.lock().unwrap().timed_out = false;
let mut context = alert_context;
context.message = format!(
"Triggering alert did not resolve itself after {} retries, This alert is paused until it resolves", RETRIES
"Triggering alert did not resolve itself after {RETRIES} retries, This alert is paused until it resolves",
);
// Send and exit this task.
call_target(target, context);
Expand Down
11 changes: 5 additions & 6 deletions server/src/banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn print_ascii_art() {
.JMML. `Moo9^Yo..JMML. M9mmmP' `Mbmmd' `Moo9^Yo. P^YbmdP' .JMML. `Mbmmd'
"#;

eprint!("{}", ascii_name);
eprint!("{ascii_name}");
eprintln!(
"
Welcome to Parseable Server!"
Expand Down Expand Up @@ -107,8 +107,8 @@ pub mod about {
impl fmt::Display for ParseableVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ParseableVersion::Version(v) => write!(f, "{}", v),
ParseableVersion::Prerelease(p) => write!(f, "{}", p),
ParseableVersion::Version(v) => write!(f, "{v}"),
ParseableVersion::Prerelease(p) => write!(f, "{p}"),
}
}
}
Expand All @@ -134,9 +134,8 @@ pub mod about {

eprintln!(
"
Commit: \"{}\"
Docs: \"https://www.parseable.io/docs\"",
commit_hash
Commit: \"{commit_hash}\"
Docs: \"https://www.parseable.io/docs\""
);
}

Expand Down
15 changes: 4 additions & 11 deletions server/src/handlers/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ pub async fn delete(req: HttpRequest) -> Result<impl Responder, StreamError> {
)
}

Ok((
format!("log stream {} deleted", stream_name),
StatusCode::OK,
))
Ok((format!("log stream {stream_name} deleted"), StatusCode::OK))
}

pub async fn list(_: HttpRequest) -> impl Responder {
Expand Down Expand Up @@ -135,8 +132,7 @@ pub async fn put_stream(req: HttpRequest) -> Result<impl Responder, StreamError>
// Error if the log stream already exists
return Err(StreamError::Custom {
msg: format!(
"log stream {} already exists, please create a new log stream with unique name",
stream_name
"log stream {stream_name} already exists, please create a new log stream with unique name"
),
status: StatusCode::BAD_REQUEST,
});
Expand Down Expand Up @@ -194,7 +190,7 @@ pub async fn put_alert(
.expect("alerts set on existing stream");

Ok((
format!("set alert configuration for log stream {}", stream_name),
format!("set alert configuration for log stream {stream_name}"),
StatusCode::OK,
))
}
Expand Down Expand Up @@ -255,10 +251,7 @@ pub async fn create_stream(stream_name: String) -> Result<(), StreamError> {
if let Err(e) = storage.create_stream(&stream_name).await {
// Fail if unable to create log stream on object store backend
return Err(StreamError::Custom {
msg: format!(
"failed to create log stream {} due to err: {}",
stream_name, e
),
msg: format!("failed to create log stream {stream_name} due to err: {e}"),
status: StatusCode::INTERNAL_SERVER_ERROR,
});
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ macro_rules! create_app {
}

fn base_path() -> String {
format!("{}/{}", API_BASE_PATH, API_VERSION)
format!("{API_BASE_PATH}/{API_VERSION}")
}

fn logstream_path(stream_name: &str) -> String {
if stream_name.is_empty() {
"/logstream".to_string()
} else {
format!("/logstream/{}", stream_name)
format!("/logstream/{stream_name}")
}
}

Expand Down
3 changes: 1 addition & 2 deletions server/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ impl Config {
cause = inner
),
Err(ObjectStorageError::AuthenticationError(inner)) => panic!(
"Failed to authenticate. Please ensure credentials are valid\n Caused by: {cause}",
cause = inner
"Failed to authenticate. Please ensure credentials are valid\n Caused by: {inner}"
),
Err(error) => {
panic!("{error}")
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl StorageDir {
+ &utils::minute_to_prefix(time.minute(), OBJECT_STORE_DATA_GRANULARITY).unwrap();
let local_uri = str::replace(&uri, "/", ".");
let hostname = utils::hostname_unchecked();
format!("{}{}.data.arrows", local_uri, hostname)
format!("{local_uri}{hostname}.data.arrows")
}

fn filename_by_current_time() -> String {
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub trait ObjectStorage: Sync + 'static {
.to_str()
.expect("filename is valid string");
let file_suffix = str::replacen(filename, ".", "/", 3);
let objectstore_path = format!("{}/{}", stream, file_suffix);
let objectstore_path = format!("{stream}/{file_suffix}");

CACHED_FILES
.lock()
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl S3 {
.client
.list_objects_v2()
.bucket(&self.bucket)
.prefix(format!("{}/", stream_name))
.prefix(format!("{stream_name}/"))
.into_paginator()
.send();

Expand Down
12 changes: 6 additions & 6 deletions server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub mod header_parsing {
return Err(ParseHeaderError::SeperatorInValue(kv_separator));
}

labels.push(format!("{}={}", key, value));
labels.push(format!("{key}={value}"));
}

if labels.len() > MAX_HEADERS_ALLOWED {
Expand Down Expand Up @@ -233,20 +233,20 @@ pub fn minute_to_slot(minute: u32, data_granularity: u32) -> Option<String> {
let block_n = minute / data_granularity;
let block_start = block_n * data_granularity;
if data_granularity == 1 {
return Some(format!("{:02}", block_start));
return Some(format!("{block_start:02}"));
}

let block_end = (block_n + 1) * data_granularity - 1;
Some(format!("{:02}-{:02}", block_start, block_end))
Some(format!("{block_start:02}-{block_end:02}"))
}

pub fn date_to_prefix(date: NaiveDate) -> String {
let date = format!("date={}/", date);
let date = format!("date={date}/");
date.replace("UTC", "")
}

pub fn hour_to_prefix(hour: u32) -> String {
format!("hour={:02}/", hour)
format!("hour={hour:02}/")
}

pub fn minute_to_prefix(minute: u32, data_granularity: u32) -> Option<String> {
Expand All @@ -272,7 +272,7 @@ impl TimePeriod {
}

pub fn generate_prefixes(&self, prefix: &str) -> Vec<String> {
let prefix = format!("{}/", prefix);
let prefix = format!("{prefix}/");

let end_minute = self.end.minute() + u32::from(self.end.second() > 0);

Expand Down