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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

skarbat
Copy link
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
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
Contributor Author

skarbat commented Oct 11, 2019

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

Copy link
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
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
* \brief Simple implementation of IHTTPClient
*/
class HTTPClient : public IHTTPClient {
public:
HTTPClient();
HTTPClient(int timeout_secs);
Copy link
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);

@@ -48,10 +48,13 @@ using Poco::Net::SSLManager;
using Mercury::HTTP::HTTPClient;


HTTPClient::HTTPClient() {
HTTPClient::HTTPClient(int timeout_secs = DEFAULT_HTTP_CLIENT_TIMEOUT) {
Copy link
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.

@@ -62,6 +65,18 @@ HTTPClient::HTTPClient() {
}


void HTTPClient::set_http_client_timeout(int seconds)
{
Copy link
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
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