-
Notifications
You must be signed in to change notification settings - Fork 583
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
SendGridClient thread-safety documentation #521
Comments
Hello @william-gross, While I have not done any specific testing for thread safety, I believe your assumption is correct with regards to I will leave this thread open so that we can create a test that verifies and documents thread safety with a real world example. For this issue to gain priority in our backlog, we need additional +1's or a PR. When we receive a PR, that provides the biggest jump in priority. With Best Regards, Elmer |
I'd like to know this as well for DI purposes. |
Thanks @paultechguy, I've add your vote to our backlog. |
I would also like to have this confirmed. |
Thanks for the upvote @winzig. |
Another Up from me 👍 :) |
Still no confirmation? |
Hi @profet23, Not yet, but I've added your vote to help this issue rise in priority. Thanks! With Best Regards, Elmer |
Please 👍 |
Thanks for the vote @kierenj! |
Up |
@thinkingserious Could you please update us on the issue? |
Also a vote from me, etc! Can we |
Hello @MSC-AA, This one is still on our backlog. We are hoping to increase our resources internally soon to help us power through our backlog faster. If you know anyone, please let us know at dx@sendgrid.com. Thanks for checking in! With Best Regards, Elmer |
Referencing: #847 |
I want to find out it too, can we use Singleton or not. |
Another vote from me! |
Another vote from me! |
Me too! |
It's very strange that SendGrid does not know if their own client is thread safe or not... This is important details, e.g. Microsoft's DbContext is not thread safe, so we need to instantiate a new instance every time we need it, on the other hand Elasticsearch client is thread safe, so we need to reuse the same instance for the entire lifetime of the application. Getting this wrong would have severe consequences, for example Elasticsearch does all the caching in the client, so if we keep instantiating a new instance we won't have any cache. Unfortunately, people who come across this thread would lose confidence in your product... |
Given that the SendGridClient class encapsulates a HttpClient instance field, it would seem to me that using it as a singleton would at least potentially have the issues documented with HttpClient singletons:
So at least from that perspective, it seems wise to use scoped lifetime even if otherwise thread safe? |
Up and also up for the comment of @HoomanBahreini... The question has been asked 3 years ago and no one is able to say whether SendGrid is thread safe or not o_O That's insane... |
@ssougnez I was going to come in here, agree with you AND also suggest that the lack of any response speaks volumes about SG and what they think about .NET Devs (with respect to using/consuming their product). --BUT-- 4 days go @childish-sambino changes the tags on this issue ... which actually looks like the first type of interaction (on this thread) since Q3 2018 - nearly 2 years ago. so maybe.... they are interested again? not sure. It's pretty frustrating, none-the-less. |
SendEmailAsync is thread safe. First thing it does is
Nothing unsafe for threads here. Using only local variables. Then it is executing method from base class. I assume that fields/props inside
Creates local var from readonly object - thread safe
creates local variable from method params - thread safe.
Does some operations on local object with help of readonly field - thread safe.
Thread safe - we are only operating on local object.
This is thread safe op.
using local variable and readonly thingy - thread safe.
Only local variable - thread safe.
Only local var - thread safe. I did not find anything thread unsafe even if you share httpClient (but i suggest using httpclientfactory). |
Please state in the documentation whether it is safe to create a single
SendGridClient
object and share it among all threads in an app domain. In particular, I'd like to know if it is safe for multiple threads in an ASP.NET application to callSendEmailAsync
orRequestAsync
at the same time.I believe this was safe in version 6.3.4 (with
SendGrid.Web.DeliverAsync
) and it's probably still safe now (since the underlying implementation isHttpClient
), but it would be nice to know for sure.The text was updated successfully, but these errors were encountered: