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

Allow SendOptions with delayed delivery constraints to be reused #5235

Merged
merged 2 commits into from
Aug 20, 2018

Conversation

timbussmann
Copy link
Contributor

fixes #5147

ping @SeanFeldman

@timbussmann timbussmann requested a review from a team August 16, 2018 09:56
@andreasohlund
Copy link
Member

Is there any way to cover this with a test?

@timbussmann
Copy link
Contributor Author

Is there any way to cover this with a test?

the extension methods are already under unit tests. Not sure this is worth an acceptance test?

@andreasohlund
Copy link
Member

Was thinking about the case where the TM screws up the delivery constraints?

@timbussmann
Copy link
Contributor Author

@andreasohlund I've added an acceptance tests from the perspective of "defect driven testing". I think this leaves a certain gap of testing other send options about their reusability, but I guess it doesn't hurt to have this test.

@@ -20,12 +18,12 @@ public static void DelayDeliveryWith(this SendOptions options, TimeSpan delay)
Guard.AgainstNull(nameof(options), options);
Guard.AgainstNegative(nameof(delay), delay);

if (options.GetExtensions().TryGetDeliveryConstraint(out DoNotDeliverBefore _))
if (options.DelayedDeliveryConstraint is DoNotDeliverBefore)
Copy link
Member

Choose a reason for hiding this comment

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

Now that we aren't just adding delivery constraints to the bag for each call, we could remove this check. That means the last one called would be the one that gets used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Had a chat with @bording about this comment. It makes sense to get rid of these ifs.

Copy link
Member

Choose a reason for hiding this comment

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

Though to be 100% completely safe, maybe we should keep them.

Copy link
Member

Choose a reason for hiding this comment

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

Last one wins make sense to me. It could be argued that it would be a breaking change to remove but I can't see how a user could rely on us throwing so I'm 👍 to remove since that code will always be causing confusion and adding an issue to remove in v8 seems overkill?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👎 for removing the check. I still think it makes sense to prevent setups like

options.DelayDeliveryWith(...)
options.DoNotDeliverBefore(...)

for calls to the same API, last-one-wins is already active.

Copy link
Contributor

Choose a reason for hiding this comment

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

@timbussmann I also thought that we should guard against this scenario and throw early rather than users to discover they are doing something wrong much later in the game.

Assuming I'm sending messages and set delayed delivery constraint conditionally, I'd probably create two SendOptions and use accordingly. Will not call the two methods on the same object to alternate between delayed delivery constraints. What would be the use case where both options would be applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would be the use case where both options would be applied?

none. That would very likely be a mistake (maybe by reusing some code) which we should provide.

@andreasohlund andreasohlund merged commit 053e523 into develop Aug 20, 2018
@andreasohlund andreasohlund deleted the delayed-delivery-send-options branch August 20, 2018 07:01
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.

When re-using SendOptions delayed delivery settings are discarded
5 participants