Skip to content

[OS-1068] Provide a timeout to the Http class#52

Open
skarbat wants to merge 2 commits intomasterfrom
http_timeout
Open

[OS-1068] Provide a timeout to the Http class#52
skarbat wants to merge 2 commits intomasterfrom
http_timeout

Conversation

@skarbat
Copy link
Copy Markdown
Contributor

@skarbat skarbat commented Oct 11, 2019

Provide a means to set a timeout for the HTTP class.
It builds fine but haven't actually tested.
Also, needs a test to make sure the timeout is set and works correctly.

@radujipa
Copy link
Copy Markdown
Contributor

I've not looked at it yet, but please let's not merge until we fix the issue we are seeing in Dashboard with Python. Then we'll focus on adding this.

@skarbat
Copy link
Copy Markdown
Contributor Author

skarbat commented Oct 11, 2019

absolutely agreed @radujipa - just wanted to get this code in a PR in the meantime.

Copy link
Copy Markdown
Member

@tombettany tombettany left a comment

Choose a reason for hiding this comment

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

Great idea, just a couple of suggestions.

namespace Mercury {
namespace HTTP {

#define DEFAULT_HTTP_CLIENT_TIMEOUT 15 // seconds
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#define DEFAULT_HTTP_CLIENT_TIMEOUT 15 // seconds
const unsigned int DEFAULT_HTTP_CLIENT_TIMEOUT = 15; // seconds

Also, is 15 seconds too long?

class HTTPClient : public IHTTPClient {
public:
HTTPClient();
HTTPClient(int timeout_secs);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Combine these two constructors into one?

Suggested change
HTTPClient(int timeout_secs);
HTTPClient(int timeout_secs = DEFAULT_HTTP_CLIENT_TIMEOUT);



HTTPClient::HTTPClient() {
HTTPClient::HTTPClient(int timeout_secs = DEFAULT_HTTP_CLIENT_TIMEOUT) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Default arguments in header definition, not implementation.



void HTTPClient::set_http_client_timeout(int seconds)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

{ on same line as definition.

}


int HTTPClient::get_http_client_timeout()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants