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

Adds debouncing FileSystemWatcher events #129

Merged
merged 5 commits into from
Mar 10, 2020
Merged

Adds debouncing FileSystemWatcher events #129

merged 5 commits into from
Mar 10, 2020

Conversation

thoemmi
Copy link
Contributor

@thoemmi thoemmi commented Mar 4, 2020

I've noticed your comment in PluginLoader:

* Debounce changes. When files are written in-place, there can be multiple events within a few milliseconds.

This PR is my proposal for a fix. It introduces a debouncer component to decouple FileSystemWatcher's events. The default delay is 200 msecs, but you can configure it with PluginConfig.ReloadDelay. If you think another default value is reasonable, feel free to change it.

@thoemmi thoemmi requested a review from natemcmaster as a code owner March 4, 2020 21:29
…libabries, not the actual connection to the database)
@thoemmi
Copy link
Contributor Author

thoemmi commented Mar 4, 2020

I had to catch SQL timeout exceptions in SqlClientApp in a failing unit test to please the build pipeline.

Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I appreciate you taking time to write some code. This is definitely something I would like to merge into this library. I just have one question and a comment before I do (see below)

return !string.IsNullOrEmpty(client.ServerVersion);
}
}
catch (SqlException ex) when (ex.Number == -2) // -2 means SQL timeout
Copy link
Owner

Choose a reason for hiding this comment

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

Why did the SqlException start happening with this change? Was it consistent, or just a flaky test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dunno, the build pipleline failed: https://github.com/natemcmaster/DotNetCorePlugins/runs/486084609
I'm not sure if it has been a transient error.

Copy link
Owner

Choose a reason for hiding this comment

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

I haven't seen it before. This test isn't using reloading though, so it's probably not related to this change.


namespace McMaster.NETCore.Plugins.Internal
{
internal class Debouncer : IDisposable
Copy link
Owner

Choose a reason for hiding this comment

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

Can we add some unit tests for this to verify its behavior (and prevent regressions in the future)?

Copy link
Contributor Author

@thoemmi thoemmi Mar 9, 2020

Choose a reason for hiding this comment

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

I've pushed some unit tests. Do you think they're sufficient?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, thank you!

Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@natemcmaster natemcmaster merged commit 4effc38 into natemcmaster:master Mar 10, 2020
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