Skip to content
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

refactor: refactor the resource reader #2290

Conversation

laststylebender14
Copy link
Contributor

@laststylebender14 laststylebender14 commented Jun 26, 2024

Summary:
Briefly describe the changes made in this PR.

Issue Reference(s):
Fixes #... (Replace "..." with the issue number)

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

@github-actions github-actions bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Jun 26, 2024
let response = reader.get(&url, headers).await?;
input_samples.push(Input::Json { url: url.parse()?, response, field_name });
let mut request = reqwest::Request::new(reqwest::Method::GET, url.parse()?);
if let Some(headers_inner) = headers {
Copy link
Contributor Author

@laststylebender14 laststylebender14 Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do something better for this else we've to convert the BTreeMap to HeaderMap.
can use TryFrom trait.

@laststylebender14 laststylebender14 marked this pull request as draft June 26, 2024 18:17
.execute(reqwest::Request::new(reqwest::Method::GET, url))
.await?;

async fn read<T: Into<Resource> + ToString + Send>(&self, file: T) -> anyhow::Result<FileRead> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async fn read<T: Into<Resource> + ToString + Send>(&self, file: T) -> anyhow::Result<FileRead> {
async fn read<T: Into<Resource> + Send>(&self, file: T) -> anyhow::Result<FileRead> {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -16,48 +14,73 @@ pub struct FileRead {
pub path: String,
}

/// Supported Resources by Resource Reader
pub enum Resource {
File(String),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
File(String),
RawPath(String),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@laststylebender14 laststylebender14 marked this pull request as ready for review June 27, 2024 18:37
@tusharmath tusharmath merged commit a1d5c2e into feat/add-support-for-headers-in-request Jun 28, 2024
6 checks passed
@tusharmath tusharmath deleted the refactor/refactor-the-resource-reader branch June 28, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore Routine tasks like conversions, reorganization, and maintenance work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants