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

SendGrid ServiceProvider Overload #2301

Merged

Conversation

cmeyertons
Copy link
Contributor

@cmeyertons cmeyertons commented Sep 23, 2024

What this PR does / why we need it:

Adds an IServiceProvider overload for configuring SendGrid to allow for ApiKey to be pulled from DI (via options pattern, etc)

Which issue(s) this PR fixes:

Please reference the issue this PR will close: #2300

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Not really, no breakages, just a new overload

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Unit tests passing
  • End-to-end tests passing
  • Extended the documentation - n/a?
  • Provided sample for the feature - tests are the sample?

@cmeyertons
Copy link
Contributor Author

idk who approved the workflow previously, but thank you 😄

I have updated the public api txt file

@cmeyertons
Copy link
Contributor Author

can i get this merged?

Copy link
Collaborator

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@cmeyertons thank you for your contribution! Overall it LGTM, but please answer to my test question. Thanks!

var check = registration.Factory(serviceProvider);

registration.Name.ShouldBe("sendgrid");
check.ShouldBeOfType<SendGridHealthCheck>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do I read this correctly that this test is not veryfing if value my_api_key has been actually used by the health check?

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 used the same assertion code that was acceptable for the previous test.

@@ -31,13 +31,41 @@ public static IHealthChecksBuilder AddSendGrid(
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
var registrationName = name ?? NAME;
return builder.AddSendGrid(_ => apiKey, name, failureStatus, tags, timeout);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we are now capturing a closure (so there is a performance) penalty, but it helps to reduce code duplication, so I am fine with that. We may however, change that approach in the future.

Copy link
Collaborator

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @cmeyertons !

@adamsitnik adamsitnik merged commit b1fe32f into Xabaril:master Dec 4, 2024
2 checks passed
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.02%. Comparing base (4a49dfa) to head (f2ac47f).
Report is 41 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2301      +/-   ##
==========================================
- Coverage   64.25%   64.02%   -0.24%     
==========================================
  Files         248      247       -1     
  Lines        8399     8291     -108     
  Branches      590      574      -16     
==========================================
- Hits         5397     5308      -89     
+ Misses       2853     2839      -14     
+ Partials      149      144       -5     
Flag Coverage Δ
SendGrid 17.21% <100.00%> (+4.02%) ⬆️

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.

@adamsitnik adamsitnik added this to the 9.0 milestone Dec 4, 2024
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.

SendGrid IServiceProvider Overload
3 participants