-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace FileSourceParams path with URI #5104
Conversation
373435a
to
afd7868
Compare
e34d436
to
383850e
Compare
assert!(cache_directory_path.read_dir().unwrap().next().is_none()); | ||
|
||
let does_not_exit_uri = uri_from_path(&test_env.data_dir_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let does_not_exit_uri = uri_from_path(&test_env.data_dir_path) | |
let does_not_exist_uri = uri_from_path(&test_env.data_dir_path) |
} | ||
|
||
/// Deserializing as an URI | ||
fn uri_from_str<'de, D>(deserializer: D) -> Result<Option<Uri>, D::Error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uri
implements Deserialize
, so I don't think we need a custom deserializer for Option<Uri>
.
@@ -249,37 +254,33 @@ pub struct FileSourceParams { | |||
#[schema(value_type = String)] | |||
#[serde(skip_serializing_if = "Option::is_none")] | |||
#[serde(default)] | |||
#[serde(deserialize_with = "absolute_filepath_from_str")] | |||
pub filepath: Option<PathBuf>, //< If None read from stdin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could rename this field file_uri
and use an alias to maintain backward compatibility.
}) | ||
} | ||
|
||
pub fn file_from_str<P: AsRef<str>>(filepath: P) -> anyhow::Result<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary, it's already super easy to go from &str
to Uri
and then to a file params object.
/// TODO: we might want to replace `PathBuf` with `Uri` directly in | ||
/// `FileSourceParams` | ||
fn absolute_filepath_from_str<'de, D>(deserializer: D) -> Result<Option<PathBuf>, D::Error> | ||
impl FromStr for FileSourceParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
parsed_cust_event.uri(), | ||
PathBuf::from("s3://quickwit-test/test.json"), | ||
parsed_cust_event.uri().unwrap(), | ||
Uri::from_str("s3://quickwit-test/test.json").unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Uri
implements PartialEq
for &str
.
46208bf
to
fdc98a5
Compare
ceaaeb3
to
24887c6
Compare
fdc98a5
to
3555d3a
Compare
4b1775f
to
6c4f299
Compare
94f94ee
to
bea5d82
Compare
6c4f299
to
cbcbfda
Compare
bea5d82
to
6d6fdb1
Compare
cbcbfda
to
0c93920
Compare
Closing this in favor of #5148 that brings significant changes on top of the file source, |
Description
The
FileSourceParams
curently contains a path that is converted forth and back to a URI. This PR straitens up things to avoid these conversions.How was this PR tested?
Describe how you tested this PR.