-
Notifications
You must be signed in to change notification settings - Fork 1.1k
harden ReliableDeliveryShardingSpecs #6750
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
Merged
Aaronontheweb
merged 5 commits into
akkadotnet:dev
from
Aaronontheweb:harden-ReliableDeliverySharding-unconfirmed-spec
May 10, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cd26ce5
harden ReliableDeliveryShardingSpecs
Aaronontheweb f224840
Merge branch 'dev' into harden-ReliableDeliverySharding-unconfirmed-spec
Aaronontheweb 5f1697d
hardened spec
Aaronontheweb 5a0fb66
Merge branch 'dev' into harden-ReliableDeliverySharding-unconfirmed-spec
Aaronontheweb f8cefee
fixed the `TestConsumer` again
Aaronontheweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,15 +34,17 @@ public sealed class TestConsumer : ReceiveActor, IWithTimers | |
|
||
private readonly ILoggingAdapter _log = Context.GetLogger(); | ||
private ImmutableHashSet<(string, long)> _processed = ImmutableHashSet<(string, long)>.Empty; | ||
private readonly bool _supportRestarts = false; | ||
private int _messageCount = 0; | ||
|
||
public TestConsumer(TimeSpan delay, Func<SomeAsyncJob, bool> endCondition, IActorRef endReplyTo, | ||
IActorRef consumerController) | ||
IActorRef consumerController, bool supportRestarts = false) | ||
{ | ||
Delay = delay; | ||
EndCondition = endCondition; | ||
EndReplyTo = endReplyTo; | ||
ConsumerController = consumerController; | ||
_supportRestarts = supportRestarts; | ||
|
||
Active(); | ||
} | ||
|
@@ -73,12 +75,18 @@ private void Active() | |
_log.Info("processed [{0}] [msg: {1}] from [{2}]", job.SeqNr, job.Msg.Payload, job.ProducerId); | ||
job.ConfirmTo.Tell(global::Akka.Delivery.ConsumerController.Confirmed.Instance); | ||
|
||
if (EndCondition(job)) | ||
if (EndCondition(job) && (_messageCount > 0 || _supportRestarts)) | ||
{ | ||
_log.Debug("End at [{0}]", job.SeqNr); | ||
EndReplyTo.Tell(new Collected(_processed.Select(c => c.Item1).ToImmutableHashSet(), _messageCount + 1)); | ||
Context.Stop(Self); | ||
} | ||
else if (!_supportRestarts && EndCondition(job)) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the figure - if the |
||
// BugFix: TestConsumer was recreated by a message sent by the Sharding system, but the EndCondition was already met | ||
// and we don't want to send another Collected that is missing some of the figures. Ignore. | ||
|
||
} | ||
else | ||
{ | ||
_processed = cleanProcessed.Add(nextMsg); | ||
|
@@ -181,12 +189,12 @@ public static ConsumerController.SequencedMessage<Job> SequencedMessage(string p | |
|
||
private static Func<SomeAsyncJob, bool> ConsumerEndCondition(long seqNr) => msg => msg.SeqNr >= seqNr; | ||
|
||
public static Props PropsFor(TimeSpan delay, long seqNr, IActorRef endReplyTo, IActorRef consumerController) => | ||
Props.Create(() => new TestConsumer(delay, ConsumerEndCondition(seqNr), endReplyTo, consumerController)); | ||
public static Props PropsFor(TimeSpan delay, long seqNr, IActorRef endReplyTo, IActorRef consumerController, bool supportsRestarts = false) => | ||
Props.Create(() => new TestConsumer(delay, ConsumerEndCondition(seqNr), endReplyTo, consumerController, supportsRestarts)); | ||
|
||
public static Props PropsFor(TimeSpan delay, Func<SomeAsyncJob, bool> endCondition, IActorRef endReplyTo, | ||
IActorRef consumerController) => | ||
Props.Create(() => new TestConsumer(delay, endCondition, endReplyTo, consumerController)); | ||
IActorRef consumerController, bool supportsRestarts = false) => | ||
Props.Create(() => new TestConsumer(delay, endCondition, endReplyTo, consumerController, supportsRestarts)); | ||
|
||
public ITimerScheduler Timers { get; set; } = null!; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This might not be the only fix this tests needs, FYI. No way to know for certain other than gathering more data.