Skip to content

Commit 7755a23

Browse files
improve hostname logic
1 parent ad026eb commit 7755a23

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

src/parseable/streams.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,9 @@ impl Stream {
190190
.unwrap_or_else(|_| std::ffi::OsString::from(&Ulid::new().to_string()))
191191
.into_string()
192192
.unwrap_or_else(|_| Ulid::new().to_string())
193-
.chars()
194-
.filter(|c| c.is_alphanumeric() || *c == '-' || *c == '_')
195-
.collect::<String>()
196-
.chars()
193+
.matches(|c: char| c.is_alphanumeric() || c == '-' || c == '_')
197194
.collect::<String>();
195+
198196
if let Some(id) = &self.ingestor_id {
199197
hostname.push_str(id);
200198
}

src/storage/object_storage.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,25 +1015,19 @@ pub fn manifest_path(prefix: &str) -> RelativePathBuf {
10151015
.unwrap_or_else(|_| std::ffi::OsString::from(&Ulid::new().to_string()))
10161016
.into_string()
10171017
.unwrap_or_else(|_| Ulid::new().to_string())
1018-
.chars()
1019-
.filter(|c| c.is_alphanumeric() || *c == '-' || *c == '_')
1020-
.collect::<String>()
1021-
.chars()
1018+
.matches(|c: char| c.is_alphanumeric() || c == '-' || c == '_')
10221019
.collect::<String>();
10231020

1024-
match &PARSEABLE.options.mode {
1025-
Mode::Ingest => {
1026-
let id = INGESTOR_META
1027-
.get()
1028-
.unwrap_or_else(|| panic!("{}", INGESTOR_EXPECT))
1029-
.get_node_id();
1021+
if PARSEABLE.options.mode == Mode::Ingest {
1022+
let id = INGESTOR_META
1023+
.get()
1024+
.unwrap_or_else(|| panic!("{}", INGESTOR_EXPECT))
1025+
.get_node_id();
10301026

1031-
let manifest_file_name = format!("ingestor.{hostname}.{id}.{MANIFEST_FILE}");
1032-
RelativePathBuf::from_iter([prefix, &manifest_file_name])
1033-
}
1034-
_ => {
1035-
let manifest_file_name = format!("{hostname}.{MANIFEST_FILE}");
1036-
RelativePathBuf::from_iter([prefix, &manifest_file_name])
1037-
}
1027+
let manifest_file_name = format!("ingestor.{hostname}.{id}.{MANIFEST_FILE}");
1028+
RelativePathBuf::from_iter([prefix, &manifest_file_name])
1029+
} else {
1030+
let manifest_file_name = format!("{hostname}.{MANIFEST_FILE}");
1031+
RelativePathBuf::from_iter([prefix, &manifest_file_name])
10381032
}
10391033
}

0 commit comments

Comments
 (0)