-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enforce operation order #23
Conversation
Code formatted with |
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.
Good!
This makes at least the usage predictable, and we could add maybe some prefixes in the files if we want to have a strict ordering.
Wrote a question about the sleep.
PD: Keep in mind that to use the latest version of photofinish in our CI, we need to create a release and update the version in other projects (we have it hardcoded)
.directories | ||
.iter() | ||
.filter_map(extract_fixtures_from_directory) | ||
.flatten() | ||
.collect(); | ||
fixtures_in_directories.sort(); |
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.
dump question: Cannot you pipe the sort
after the collect? Or vectors don't allow this?
Maybe using sorted
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.
Cool, I'm not much into rust so I missed that. I'll try it
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.
To use such function I must add a dependency to itertools.
I'd rather accept to have a mutable variable instead.
src/run.rs
Outdated
Err(Errored { file, reason }) => { | ||
println!("An error occurred in loading fixture {}: {}", file, reason) | ||
} | ||
} | ||
|
||
thread::sleep(std::time::Duration::from_millis(wait)); |
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.
Are we sure about this?
This function is blocking and the docs say it shouldn't be used in async functions.
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.
Are we sure about this?
About the expected behavior: yes, I think we might need a gap between HTTP calls if we want to reduce the pressure on the receiving system (that might not be tuned for receiving a burst of requests).
About using thread::sleep
: not sure, for what I red is fine but I will investigate more
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 found out I'd better use tokio::time::sleep
. Done in 8222736
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.
LGTM, nice catch for tokio::sleep 👍
8222736
to
97b7187
Compare
Enforce the order of execution of the HTTP requests by sorting the fixture set by file name. Optionally, a
wait
argument can be provided to add a delay between HTTP requests.Rationale
As this is a tool for replaying events, I expect the ability to define the order in which events should be processed; following the alphabetical order of the files in the directory seems to be the more natural approach.
Furthermore, the
wait
parameter can slow down the ingestion rate for the receiving service, if needed.