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

chore: Generalize file server around paths provider #2541

Merged
merged 7 commits into from
May 13, 2020

Conversation

MOZGIII
Copy link
Contributor

@MOZGIII MOZGIII commented May 5, 2020

This PR generalizes the file_source::FileServer around the ways it obtains the lists of paths to work with.

The rationale for this change is we'll be using an alternative way of obtaining the lists of paths at the k8s implementation - it'll be based on the continuously updated data obtained from the k8s API.

An alternative to this change was to implement a new solution for file reading from scratch. I discouraged that because we already have an excellent implementation that can be generalized to fit the needs.

I was cautious to limit the scope of the change to the minimum, to decrease the effect on the other components.

@MOZGIII MOZGIII force-pushed the file-server-paths-provider branch from 9db5557 to 9c3866a Compare May 5, 2020 03:09
@MOZGIII MOZGIII marked this pull request as ready for review May 5, 2020 09:07
@MOZGIII MOZGIII requested a review from LucioFranco as a code owner May 5, 2020 09:07
@MOZGIII MOZGIII requested review from LucioFranco and lukesteensen and removed request for LucioFranco May 5, 2020 09:07
Copy link
Member

@lukesteensen lukesteensen left a comment

Choose a reason for hiding this comment

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

This is a nice change! I'm very glad to isolate that complexity from the rest of the file server.

current_glob_iter: Option<glob::Paths>,
}

impl<'a> Iterator for Iter<'a> {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like we're taking on a decent amount of additional complexity to implement Iterator instead of just building a Vec. Given that we can only expose Vec via the API, why not go for a simpler implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pushed an alternative implementation that's more efficient than Vec. It has some issues though: it's definitely more complex and verbose. But the good thing is it doesn't allocate the files list in memory.
I'm considering ditching that implementation and switching back to Vec, but simpler, to trade-off the code simplicity for the runtime performance.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

While this is a very cool implementation, I don't think this functionality is performance-sensitive enough to justify the additional complexity. I would rather start with something that minimizes our maintenance overhead and then optimize if/when this code is determined to be a bottleneck.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! I’m going to replace the custom iter impl with a composition of combinators.

@MOZGIII MOZGIII force-pushed the file-server-paths-provider branch from 9c3866a to 785f6a2 Compare May 11, 2020 11:26
@MOZGIII MOZGIII force-pushed the file-server-paths-provider branch from 0228c05 to 95fcb0e Compare May 11, 2020 11:56
@MOZGIII MOZGIII requested a review from lukesteensen May 12, 2020 10:16
Signed-off-by: MOZGIII <[email protected]>
Copy link
Member

@lukesteensen lukesteensen left a comment

Choose a reason for hiding this comment

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

Looks good!

@MOZGIII MOZGIII merged commit b26a0e9 into master May 13, 2020
@binarylogic binarylogic deleted the file-server-paths-provider branch July 23, 2020 17:32
mengesb pushed a commit to jacobbraaten/vector that referenced this pull request Dec 9, 2020
* Add the path provider trait and implement glob using it

Signed-off-by: MOZGIII <[email protected]>

* Swap the glob implmenetation at the FileServer with generic PathsProvider

Signed-off-by: MOZGIII <[email protected]>

* Integrate updated at `file_source` crate into the file source

Signed-off-by: MOZGIII <[email protected]>

* Switch PathsProvider to IntoIterator

Signed-off-by: MOZGIII <[email protected]>

* Implement a more advanced and efficient PathProvider for Glob

Signed-off-by: MOZGIII <[email protected]>

* Switch back to Vec but with a simpler implementation

Signed-off-by: MOZGIII <[email protected]>

* Update CODEOWNERS

Signed-off-by: MOZGIII <[email protected]>
Signed-off-by: Brian Menges <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants