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

Support SNS batch publishing #1335

Merged

Conversation

martincostello
Copy link
Member

@martincostello martincostello commented Feb 1, 2024

Add support for batch publishing messages to SNS.

Supersedes #1098.

TODO

@martincostello martincostello added enhancement dependencies Pull requests that update a dependency file .NET Pull requests that update .net code labels Feb 1, 2024
@martincostello martincostello added this to the Future milestone Feb 1, 2024
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: Patch coverage is 74.55471% with 100 lines in your changes missing coverage. Please review.

Project coverage is 78.34%. Comparing base (0abb907) to head (a23f503).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
src/JustSaying/JustSayingBus.cs 66.66% 23 Missing and 2 partials ⚠️
...ng/AwsTools/MessageHandling/SqsMessagePublisher.cs 68.42% 20 Missing and 4 partials ⚠️
...ng/AwsTools/MessageHandling/SnsMessagePublisher.cs 79.12% 15 Missing and 4 partials ⚠️
...JustSaying/Fluent/MessagingConfigurationBuilder.cs 27.77% 10 Missing and 3 partials ⚠️
...ng/Fluent/PublishConfig/DynamicMessagePublisher.cs 77.77% 6 Missing and 2 partials ⚠️
....StructureMap/ConfigurationExpressionExtensions.cs 76.47% 3 Missing and 1 partial ⚠️
.../AwsTools/MessageHandling/PublishBatchException.cs 33.33% 4 Missing ⚠️
...tSaying/Fluent/TopicAddressPublicationBuilder`1.cs 77.77% 2 Missing ⚠️
src/JustSaying/MessagingBusBuilder.cs 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1335      +/-   ##
==========================================
- Coverage   79.49%   78.34%   -1.16%     
==========================================
  Files         138      140       +2     
  Lines        3234     3556     +322     
  Branches      448      501      +53     
==========================================
+ Hits         2571     2786     +215     
- Misses        433      522      +89     
- Partials      230      248      +18     
Flag Coverage Δ
linux 78.34% <74.55%> (-1.10%) ⬇️
macos 46.45% <35.62%> (-1.60%) ⬇️
windows 46.45% <35.62%> (-1.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 3 to 5
<PackageVersion Include="AWSSDK.SimpleNotificationService" Version="3.7.300" />
<PackageVersion Include="AWSSDK.SQS" Version="3.7.300" />
Copy link
Member Author

@martincostello martincostello Feb 1, 2024

Choose a reason for hiding this comment

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

These are the minimum versions that support .NET 8 and AoT, so I think they're worth raising the baseline to as part of getting the batch publishing support.

@@ -106,10 +106,12 @@ public Uri GetQueueUriByConvention<T>()
/// <returns>The <see cref="Uri"/> for this queue.</returns>
public Uri GetQueueUri(string queueName)
{
#pragma warning disable CS0618 // Type or member is obsolete
var hostname = _regionEndpoint.GetEndpointForService("sqs").Hostname;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is obsolete, but using the new way is difficult to do for libraries without breaking compatibility or making things harder for consumers, so keeping using the old way.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will need revisiting with AWSSDK v4 as this has been removed completely.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was internal and just syntactic sugar, so I just removed it.

martincostello and others added 14 commits April 8, 2024 09:41
Add support for batch publishing messages to SNS.
Supersedes justeattakeaway#1098.

Co-Authored-By: Rafael Lillo <7280959+lillo42@users.noreply.github.com>
- Remove some new methods to reduce new public API surface.
- Add missing XML documentation.
- Some minor code style fix-ups.
Apply outstanding review comments from justeattakeaway#1098.
Add more coverage for batch publishing.
Fix two broken tests.
Ensure that messages with dynamic topics are not all sent to the topic associated with the first message in a batch.
Extend the `Interrogate()` response for a dynamic message publisher to return the publishers and the batch publishers.
Condense the syntax.
Manual editing meant a missed comma.
Refactor things to make the public API analyser happy.
Add new unshipped members to baselines.
Fix test broken by 366fd64.
Use the explicit token option, rather than setting an environment variable.
Add new batch publishing APIs.
@martincostello
Copy link
Member Author

This should be ready to test at your convenience now @hwoodiwiss.

@hwoodiwiss
Copy link
Member

Tested internally, looks good to me, it worked well. 🎉

@martincostello martincostello marked this pull request as ready for review August 28, 2024 16:00
@martincostello martincostello requested a review from a team as a code owner August 28, 2024 16:00
@martincostello
Copy link
Member Author

@slang25 Do we want to make this part of 8? If so, I'll update the version number again before merging.

Copy link
Member

@hwoodiwiss hwoodiwiss left a comment

Choose a reason for hiding this comment

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

I've reviewed down to src/JustSaying/IPublishBatchConfiguration.cs, I'll try and get back to this soon. Just a few minor changes so far.

src/JustSaying/AwsTools/JustSayingConstants.cs Outdated Show resolved Hide resolved

if (response.Successful.Count > 0 && _logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation(
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see this success log in my testing, I only saw the one that I'd added, though it did definitely successfully send the notifications.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you have a log filter configured on JustSaying messages?

Copy link
Member

Choose a reason for hiding this comment

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

No, and in the previous version, we do get the logs for individual message publishes. I'll have another look tomorrow.

src/JustSaying/Fluent/MessagingConfigurationBuilder.cs Outdated Show resolved Hide resolved
Apply feedback to comments and log messages.
Copy link
Member

@hwoodiwiss hwoodiwiss left a comment

Choose a reason for hiding this comment

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

Just a few more spelling bits, and a comment on the API surface

src/JustSaying/JustSayingBus.cs Show resolved Hide resolved
src/JustSaying/MessagingBusBuilder.cs Outdated Show resolved Hide resolved
Copy link
Member

@hwoodiwiss hwoodiwiss left a comment

Choose a reason for hiding this comment

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

I don't think these are worth blocking over, I just think it would be clearer if we disambiguated the log messages for batches.

{
if (PublishBatchConfiguration.PublishFailureReAttempts == 0)
{
_log.LogWarning("You have not set a re-attempt value for publish failures. If the publish location is not available you may lose messages.");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_log.LogWarning("You have not set a re-attempt value for publish failures. If the publish location is not available you may lose messages.");
_log.LogWarning("You have not set a re-attempt value for batch publish failures. If the publish location is not available you may lose messages.");

src/JustSaying/JustSayingBus.cs Outdated Show resolved Hide resolved
src/JustSaying/JustSayingBus.cs Outdated Show resolved Hide resolved
src/JustSaying/JustSayingBus.cs Outdated Show resolved Hide resolved
src/JustSaying/JustSayingBus.cs Outdated Show resolved Hide resolved
Copy link
Member

@hwoodiwiss hwoodiwiss left a comment

Choose a reason for hiding this comment

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

A few more spellings

- Fix typos.
- Make messages more specific to batches.
- Style refactor.
- Extend the integration tests to include publishing to multiple topics in a single batch.
- Fix broken test assertion after previous refactor.
- Disable IDE0130.
@hwoodiwiss
Copy link
Member

Do we still want to bump the major version for this, or do we want to have this as the last big thing for v7, as it should be backwards-compatible.

@slang25
Copy link
Member

slang25 commented Sep 2, 2024

A big part of me wants to put this in to a V8. The compression work is almost done (but there is a lot to review).

@martincostello
Copy link
Member Author

@slang25 What do you want to do with this PR? Is it ready to merge, or does it need to wait on something else?

Use 3.7.400 series.
Fix-up attempt to use newer AWS SDK packages.
@martincostello
Copy link
Member Author

Unless there's any objections in the next 24 hours, I'm going to merge this tomorrow and it'll just sit in main until whenever we do another release.

@martincostello martincostello merged commit 42fe0a8 into justeattakeaway:main Oct 3, 2024
12 of 14 checks passed
@martincostello martincostello deleted the support-batch-publishing branch October 3, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement .NET Pull requests that update .net code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants