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

Fix RestartStrategy::timeout < 1s #265

Merged
merged 9 commits into from
Aug 20, 2020

Conversation

nicolaiunrein
Copy link
Contributor

Fix issue where fractions of a second are ignored internally. This leads to a broken RestartStrategy when given a timeout of eg. Duration::from_millis(999). NOTE: The type casting of multiplier can get removed but that would be a breaking change. I leave this for the reviewer to decide.

Checklist
  • tests are passing with cargo test.
  • tests and/or benchmarks are included
  • commit message is clear

Fix issue where fractions of a second are ignored internally. This leads to a broken `RestartStrategy` when given a timeout of eg. `Duration::from_millis(999)`. NOTE: The type casting of `multiplier` can get removed but that would be a breaking change. I leave this for the reviewer to decide.
@o0Ignition0o o0Ignition0o requested a review from Relrin August 19, 2020 08:16
@o0Ignition0o
Copy link
Contributor

o0Ignition0o commented Aug 19, 2020

Hey, thanks a lot for the pull request!

In our first implementation, we hadn't thought of a timeout < 1 sec, so that's a very welcome patch!

I'll leave it up to @Relrin to review the changes, because I think he's been working on it the most.

He might be able to decide whether we wanna make a breaking change (there's a lot of things happening on the executor side, so we might wanna bump both at the same time).

Thanks again!

@Relrin
Copy link
Member

Relrin commented Aug 19, 2020

Hey, @nicolaiunrein

In general, it looks good. However, before merging this patch, we will need a couple of more changes:

He might be able to decide whether we wanna make a breaking change (there's a lot of things happening on the executor side, so we might wanna bump both at the same time).

I think it will be competely fine to deliver a new version with a couple of "breaking changes" in the single release. Plus, there's no significant impact on existing users because most of the users not going for exceed u32 limits in real applications.

And yeah, thanks ahead for the patch!

Copy link
Member

@Relrin Relrin left a comment

Choose a reason for hiding this comment

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

Changing the multiplier / restarts_count field types in the RestartStrategy structure to the u32 type will eliminate type converstions.

@nicolaiunrein nicolaiunrein marked this pull request as draft August 20, 2020 09:20
@Relrin Relrin marked this pull request as ready for review August 20, 2020 09:22
@nicolaiunrein
Copy link
Contributor Author

nicolaiunrein commented Aug 20, 2020

I realized that after all f64 might actually be what we want for multiplier because with an integer we are not able to increase the delay by eg. 10% on each try. The downside is that this will generate more changes:

  1. users need to change eg. 1 -> 1.0
  2. need to remove impl of Eq for ActorRestartStrategy and RestartStrategy

So feel free to undo the last commit.

@Relrin
Copy link
Member

Relrin commented Aug 20, 2020

I realized that after all f64 might actually be what we want for multiplier because with an integer we are not able to increase the delay by eg. 10% on each try. The downside is that this will generate more changes:

  1. users need to change eg. 1 -> 1.0
  2. need to remove impl of Eq for ActorRestartStrategy and RestartStrategy

In practice this is a quite rare case, and for the most users is more than enough to have a delay calculated with integer values. So, I think it's reasonable to left it as it for now :)

@o0Ignition0o
Copy link
Contributor

I think we're a cargo fmt away from merging it ! 🎉

@nicolaiunrein
Copy link
Contributor Author

Do you want me to revert to u32?

@Relrin
Copy link
Member

Relrin commented Aug 20, 2020

Yes, please, revert it back to the u32 type

@o0Ignition0o
Copy link
Contributor

Amazing, thanks a lot for your contribution! 🎉

@o0Ignition0o o0Ignition0o merged commit 75904cf into bastion-rs:master Aug 20, 2020
Relrin added a commit that referenced this pull request Oct 25, 2020
* dispatch to available children only. (#268)

* Fix RestartStrategy::timeout < 1s (#265)

* Renamed ActorStateData struct to Context

* Extended available states for Actor

* Added methods for additional states

* Added removed state

* Added definition module

* Added Definition struct

* Removed unsafe Send and Sync implementation for MailboxTx

* Added docstrings for Mailbox<T>

* Added tests for the Definition struct

* Added presaving messages

* Removed excessive imports

* Added methods for getting latest message

* Removed reference for the returned envelope

* Code review changes

Co-authored-by: Jeremy Lempereur <[email protected]>
Co-authored-by: nicolaiunrein <[email protected]>
o0Ignition0o pushed a commit that referenced this pull request Apr 14, 2021
* dispatch to available children only. (#268)

* Fix RestartStrategy::timeout < 1s (#265)

* Renamed ActorStateData struct to Context

* Extended available states for Actor

* Added methods for additional states

* Added removed state

* Added definition module

* Added Definition struct

* Removed unsafe Send and Sync implementation for MailboxTx

* Added docstrings for Mailbox<T>

* Added tests for the Definition struct

* Added presaving messages

* Removed excessive imports

* Added methods for getting latest message

* Removed reference for the returned envelope

* Code review changes
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.

3 participants