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

Improve Streams Throttle. Log errors, improve tests, and add supervisor strategy support #6886

Merged
merged 6 commits into from
Aug 17, 2023

Conversation

Arkatufus
Copy link
Contributor

Fixes #6406

Changes

  • Add supervisor strategy support for failing colculateCost delegate
  • Add unit test
  • Rewrite nonsensical tests to proper async tests

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Need to address issue of what happens when we're "enforcing" throttling?

@@ -46,66 +49,101 @@ private static ByteString GenerateByteString(int length)
return ByteString.FromBytes(bytes);
}

[Fact(DisplayName = "Throttle with delegate calculateCost must resume when delegate throws")]
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@@ -1893,7 +1893,7 @@ public SplitAfterMergeBack(IFlow<TOut, TMat> self, Func<TOut, bool> predicate, S
int maximumBurst, ThrottleMode mode)
{
if (elements <= 0) throw new ArgumentException("Throttle elements must be > 0", nameof(elements));
if (per == TimeSpan.Zero) throw new ArgumentException("Throttle per timeout must not be zero", nameof(per));
if (per <= TimeSpan.Zero) throw new ArgumentException("Throttle per timeout must not be less than or equal to zero", nameof(per));
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

else
{
if (_enforcing)
throw new OverflowException("Maximum throttle throughput exceeded.");
Copy link
Member

Choose a reason for hiding this comment

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

Problem: if we're enforcing, do we need to fail regardless of what the supervision strategy says?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should fail regardless, I'll change the code

Copy link
Member

Choose a reason for hiding this comment

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

I agree

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) August 17, 2023 14:09
@Aaronontheweb Aaronontheweb merged commit 9942ad9 into akkadotnet:dev Aug 17, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Akka.Streams] Supervisor strategy is not applied when calculateCost throws an exception in Throttle
2 participants