Skip to content

Conversation

@jonnybee
Copy link
Contributor

Changed SendGridClient to keep/reuse HttpClient instance
Removed obsolete properties and parameters (that cannot be re-set on the HttpClient)
Modified unit tests to pass custom headers to SendGridClient constructor
Change in Examples to avoid exception when there is no groups and correct text message.

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Mar 12, 2017
public async Task<Response> MakeRequest(HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken = default(CancellationToken))
public async Task<Response> MakeRequest(HttpRequestMessage request, CancellationToken cancellationToken = default(CancellationToken))
{
HttpResponseMessage response = await client.SendAsync(request, cancellationToken).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why drop the .ConfigureAwait(false);? I believe we had async issues before without this call. Please see this thread: #362

@jonnybee
Copy link
Contributor Author

Done. Learned a new thing now about why use ConfigureAwait(false) in libraries.

Copy link
Contributor

@thinkingserious thinkingserious left a comment

Choose a reason for hiding this comment

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

Great work! I just have few more requests. Thank you!

/// <returns>Interface to the SendGrid REST API</returns>
public SendGridClient(IWebProxy webProxy, string apiKey, string host = "https://api.sendgrid.com", Dictionary<string, string> requestHeaders = null, string version = "v3", string urlPath = null)
: this(apiKey, host, requestHeaders, version, urlPath)
public SendGridClient(IWebProxy webProxy, string apiKey, string host = null, Dictionary<string, string> requestHeaders = null, string version = "v3")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please re-add the urlPath parameter so we can avoid a breaking change. It allows for the user to specify a default endpoint path.

/// <param name="urlPath">Path to endpoint (e.g. /path/to/endpoint)</param>
/// <returns>Interface to the SendGrid REST API</returns>
public SendGridClient(string apiKey, string host = null, Dictionary<string, string> requestHeaders = null, string version = "v3", string urlPath = null)
public SendGridClient(string apiKey, string host = null, Dictionary<string, string> requestHeaders = null, string version = "v3")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please re-add the urlPath parameter so we can avoid a breaking change. It allows for the user to specify a default endpoint path.

/// The web proxy.
/// </summary>
private IWebProxy webProxy;
private readonly string version;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include summary comments.

Added summary comments
@jonnybee
Copy link
Contributor Author

Done.

Copy link
Contributor

@thinkingserious thinkingserious left a comment

Choose a reason for hiding this comment

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

Looks like we are almost there. I just have one more question.

/// <param name="urlPath">Path to endpoint (e.g. /path/to/endpoint)</param>
/// <returns>Interface to the SendGrid REST API</returns>
public SendGridClient(IWebProxy webProxy, string apiKey, string host = "https://api.sendgrid.com", Dictionary<string, string> requestHeaders = null, string version = "v3", string urlPath = null)
: this(apiKey, host, requestHeaders, version, urlPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why this line was removed.

/// <param name="urlPath">Path to endpoint (e.g. /path/to/endpoint)</param>
/// <returns>Interface to the SendGrid REST API</returns>
public SendGridClient(string apiKey, string host = null, Dictionary<string, string> requestHeaders = null, string version = "v3", string urlPath = null)
: this(null, apiKey, host, requestHeaders, version, urlPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

.. and then this line added here.

@jonnybee
Copy link
Contributor Author

New version create the HttpClient in ctor and this is done in the ctor that accepts all parameters (WebProxy).

Previous version of this ctor would call the other ctor (without the webproxy parameter) and then just set the WebPoxy property.

@thinkingserious
Copy link
Contributor

That makes sense, and thanks for responding so quickly. My main concern is that this may cause a breaking change because the function signatures are no longer the same. I will double check the tests and make sure code written against the previous versions of those constructors do not break.

@thinkingserious thinkingserious merged commit 7ea44d6 into sendgrid:master Mar 20, 2017
@thinkingserious
Copy link
Contributor

Thanks again for the awesome PR! Please take a moment to fill out this form so that we can send you some swag :)

@jonnybee jonnybee deleted the #405_Reuse_HttpClient branch March 20, 2017 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: code review request requesting a community code review or review from Twilio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants