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

Attempt to resolve ConnectTimeoutError #27

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/embulk/input/zendesk/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ def initialize(config)
end

def httpclient
httpclient = HTTPClient.new
httpclient.connect_timeout = 240 # default:60 is not enough for huge data
# httpclient.debug_dev = STDOUT
set_auth(httpclient)
# multi-threading + retry can create lot of instances, and each will keep connecting
# re-using instance in multi threads can help to omit cleanup code
@httpclient ||=
begin
clnt = HTTPClient.new
clnt.connect_timeout = 240 # default:60 is not enough for huge data
clnt.receive_timeout = 240 # better change default receive_timeout too
# httpclient.debug_dev = STDOUT
set_auth(clnt)
end
end

def pool
Expand Down
7 changes: 7 additions & 0 deletions test/embulk/input/zendesk/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ def stub_response(status, headers = [], body_json = nil)
end
end

sub_test_case "should not create new instance of httpclient" do
test "not create new instance when re-call" do
client = Client.new(login_url: login_url, auth_method: "token", username: username, token: token)
assert client.httpclient == client.httpclient
end
end

def login_url
"http://example.com"
end
Expand Down