Skip to content

Commit 89807da

Browse files
authored
Inline format arg (#274)
1 parent 61d3e21 commit 89807da

File tree

10 files changed

+23
-35
lines changed

10 files changed

+23
-35
lines changed

server/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ fn main() {
2424
*config.git_mut().sha_kind_mut() = ShaKind::Short;
2525

2626
if let Err(e) = vergen(config) {
27-
println!(
28-
"cargo:warning=initializing vergen failed due to error: {}",
29-
e
30-
);
27+
println!("cargo:warning=initializing vergen failed due to error: {e}",);
3128
}
3229

3330
println!("cargo:rerun-if-changed=build.rs");

server/src/alerts/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Target {
106106
state.lock().unwrap().timed_out = false;
107107
let mut context = alert_context;
108108
context.message = format!(
109-
"Triggering alert did not resolve itself after {} retries, This alert is paused until it resolves", RETRIES
109+
"Triggering alert did not resolve itself after {RETRIES} retries, This alert is paused until it resolves",
110110
);
111111
// Send and exit this task.
112112
call_target(target, context);

server/src/banner.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn print_ascii_art() {
4242
.JMML. `Moo9^Yo..JMML. M9mmmP' `Mbmmd' `Moo9^Yo. P^YbmdP' .JMML. `Mbmmd'
4343
"#;
4444

45-
eprint!("{}", ascii_name);
45+
eprint!("{ascii_name}");
4646
eprintln!(
4747
"
4848
Welcome to Parseable Server!"
@@ -107,8 +107,8 @@ pub mod about {
107107
impl fmt::Display for ParseableVersion {
108108
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
109109
match self {
110-
ParseableVersion::Version(v) => write!(f, "{}", v),
111-
ParseableVersion::Prerelease(p) => write!(f, "{}", p),
110+
ParseableVersion::Version(v) => write!(f, "{v}"),
111+
ParseableVersion::Prerelease(p) => write!(f, "{p}"),
112112
}
113113
}
114114
}
@@ -134,9 +134,8 @@ pub mod about {
134134

135135
eprintln!(
136136
"
137-
Commit: \"{}\"
138-
Docs: \"https://www.parseable.io/docs\"",
139-
commit_hash
137+
Commit: \"{commit_hash}\"
138+
Docs: \"https://www.parseable.io/docs\""
140139
);
141140
}
142141

server/src/handlers/logstream.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ pub async fn delete(req: HttpRequest) -> Result<impl Responder, StreamError> {
6060
)
6161
}
6262

63-
Ok((
64-
format!("log stream {} deleted", stream_name),
65-
StatusCode::OK,
66-
))
63+
Ok((format!("log stream {stream_name} deleted"), StatusCode::OK))
6764
}
6865

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

196192
Ok((
197-
format!("set alert configuration for log stream {}", stream_name),
193+
format!("set alert configuration for log stream {stream_name}"),
198194
StatusCode::OK,
199195
))
200196
}
@@ -255,10 +251,7 @@ pub async fn create_stream(stream_name: String) -> Result<(), StreamError> {
255251
if let Err(e) = storage.create_stream(&stream_name).await {
256252
// Fail if unable to create log stream on object store backend
257253
return Err(StreamError::Custom {
258-
msg: format!(
259-
"failed to create log stream {} due to err: {}",
260-
stream_name, e
261-
),
254+
msg: format!("failed to create log stream {stream_name} due to err: {e}"),
262255
status: StatusCode::INTERNAL_SERVER_ERROR,
263256
});
264257
}

server/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,14 @@ macro_rules! create_app {
325325
}
326326

327327
fn base_path() -> String {
328-
format!("{}/{}", API_BASE_PATH, API_VERSION)
328+
format!("{API_BASE_PATH}/{API_VERSION}")
329329
}
330330

331331
fn logstream_path(stream_name: &str) -> String {
332332
if stream_name.is_empty() {
333333
"/logstream".to_string()
334334
} else {
335-
format!("/logstream/{}", stream_name)
335+
format!("/logstream/{stream_name}")
336336
}
337337
}
338338

server/src/option.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ impl Config {
104104
cause = inner
105105
),
106106
Err(ObjectStorageError::AuthenticationError(inner)) => panic!(
107-
"Failed to authenticate. Please ensure credentials are valid\n Caused by: {cause}",
108-
cause = inner
107+
"Failed to authenticate. Please ensure credentials are valid\n Caused by: {inner}"
109108
),
110109
Err(error) => {
111110
panic!("{error}")

server/src/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl StorageDir {
211211
+ &utils::minute_to_prefix(time.minute(), OBJECT_STORE_DATA_GRANULARITY).unwrap();
212212
let local_uri = str::replace(&uri, "/", ".");
213213
let hostname = utils::hostname_unchecked();
214-
format!("{}{}.data.arrows", local_uri, hostname)
214+
format!("{local_uri}{hostname}.data.arrows")
215215
}
216216

217217
fn filename_by_current_time() -> String {

server/src/storage/object_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub trait ObjectStorage: Sync + 'static {
245245
.to_str()
246246
.expect("filename is valid string");
247247
let file_suffix = str::replacen(filename, ".", "/", 3);
248-
let objectstore_path = format!("{}/{}", stream, file_suffix);
248+
let objectstore_path = format!("{stream}/{file_suffix}");
249249

250250
CACHED_FILES
251251
.lock()

server/src/storage/s3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl S3 {
180180
.client
181181
.list_objects_v2()
182182
.bucket(&self.bucket)
183-
.prefix(format!("{}/", stream_name))
183+
.prefix(format!("{stream_name}/"))
184184
.into_paginator()
185185
.send();
186186

server/src/utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub mod header_parsing {
7171
return Err(ParseHeaderError::SeperatorInValue(kv_separator));
7272
}
7373

74-
labels.push(format!("{}={}", key, value));
74+
labels.push(format!("{key}={value}"));
7575
}
7676

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)