-
Notifications
You must be signed in to change notification settings - Fork 229
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
Frequently written files may get debounced indefinitely #183
Conversation
2) When Write is emitted, we disable onGoingWrite.
…ventLoop's channel 2) This will then set on_going_write's delay in WatchTimer.
2) Refactoring.
@passcod |
What's with all the commented out code? |
Remnants of my previous attempts to fix this. Cleaned them up. |
Yeah, tests are flaky, especially on Travis (likely to do with the virtualisation or something... testing three times per platform tends to help eliminate things out). I usually get them to retry, but I missed that one as I haven't had the time to review this PR in depth last week. |
Looks like tests passed. Yaay!! I’m also going to add few more tests cases for the new event depending on your your feedback. Sent with GitHawk |
sorry, no. I'm focused on an upcoming release at work, will have time next
week
…On Fri, 15 Mar 2019 at 09:44, Sujit Joshi ***@***.***> wrote:
@passcod <https://github.com/passcod> Did you get a change to look at
this PR? I have another PR
<xi-editor/xi-editor#1011> that is waiting for
this. There is no rust at all. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAJgiwb796xfjRVC71mpQPybPwDa9jqpks5vWrS_gaJpZM4bde5L>
.
|
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.
General:
- needs the documentation
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.
Looks good! Some more general things:
-
The correct spelling of the word is "ongoing", no spaces and no hyphens, so all the methods should be
set_ongoing_...
and the types should beOngoingWrite
,ONGOING_WRITE
, etc. -
This falls under "documentation", but as a note, we should provide some guidance as to what the duration should be, especially in relation to the debounce duration.
-
The method
set_ongoing_write_duration
is a bit awkward. What that method does is both "switch on the OngoingWrite event, and configure the interval duration" and "re-configure the interval duration" depending on context. The current name implies only the configuring part and it's not obvious that it may be turning on the feature. -
We provide a way to turn ongoing write events on, but no way to turn them off. That should probably be allowed.
There's several ways to do this, but I think what would be most forward-looking here is adding a new configure(&mut self, option: Config) -> Result<()>;
method and making a Config enum that would initially look like:
enum Config {
OngoingWrites(Option<Duration>),
}
So usage would be like:
watcher.configure(Config::OngoingWrites(Some(Duration::from_ms(50))))?;
watcher.configure(Config::OngoingWrites(None))?;
That takes care of the method name and brings it in line with the other ones (single verbs), and also means that any further runtime options can be added there without more bikeshedding.
Functionally, the trait would contain a default implementation that just returns Ok(())
for everything, and most everything else would keep working the same.
All suggestions are valid and are included. I liked the idea of making is configurable. Made changes accordingly. |
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.
Alright! That's looking good. I'll merge later today (or tomorrow depending on how life goes).
@@ -611,6 +615,25 @@ pub trait Watcher: Sized { | |||
/// Returns an error in the case that `path` has not been watched or if removing the watch | |||
/// fails. | |||
fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>; | |||
|
|||
/// Configure notify with Configs. | |||
fn configure(&self, option: Config) -> Result<()> { |
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.
Thinking more about this...should I make this a collection of Config rather than just a Config?
That would probably complicate things. Calling configure multiple times is
fine, but accepting a collection would mean doing deduplication or conflict
detection or have odd behaviour (what should passing
Config::OngoingWrite(Some(...)) and Config::OngoingWrite(None) do?)
That can be added/changed later as needed.
…On Tue, 26 Mar 2019, 02:57 Sujit Joshi, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/lib.rs
<#183 (comment)>:
> @@ -611,6 +615,25 @@ pub trait Watcher: Sized {
/// Returns an error in the case that `path` has not been watched or if removing the watch
/// fails.
fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
+
+ /// Configure notify with Configs.
+ fn configure(&self, option: Config) -> Result<()> {
Thinking more about this...should I make this a collection of Config
rather than just a Config?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJgi8CTXwj3Eelw-I9oEiI44IXrbNerks5vaNXTgaJpZM4bde5L>
.
|
Fair enough. I’ll keep this the way it is.
On Mon, Mar 25, 2019 at 3:25 PM Félix Saparelli <[email protected]>
wrote:
That would probably complicate things. Calling configure multiple times is
fine, but accepting a collection would mean doing deduplication or conflict
detection or have odd behaviour (what should passing
Config::OngoingWrite(Some(...)) and Config::OngoingWrite(None) do?)
That can be added/changed later as needed.
On Tue, 26 Mar 2019, 02:57 Sujit Joshi, ***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/lib.rs
> <#183 (comment)>:
>
> > @@ -611,6 +615,25 @@ pub trait Watcher: Sized {
> /// Returns an error in the case that `path` has not been watched or if
removing the watch
> /// fails.
> fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
> +
> + /// Configure notify with Configs.
> + fn configure(&self, option: Config) -> Result<()> {
>
> Thinking more about this...should I make this a collection of Config
> rather than just a Config?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#183 (review)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AAJgi8CTXwj3Eelw-I9oEiI44IXrbNerks5vaNXTgaJpZM4bde5L
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#183 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGcDclRXcMWvnCKZVa3_nOKDoWnhO_Tcks5vaSKpgaJpZM4bde5L>
.
--
Thank you.
- Sujit Joshi.
|
Thanks for merging. 👍 |
This PR is for issue 146. It contains:
OnGoingWrite
which is optional by default to keep existing clients unchanged.WRITE
events.WRITE
event is fired, this event is unscheduled.I have made changes for linux and macos platforms. I haven't made for Windows because I don't have access to one. But I'll find a way to get it.