Skip to content

Commit 10145f9

Browse files
committed
chore: ruby timeouts
1 parent 0b4332b commit 10145f9

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

clients/algoliasearch-client-ruby/lib/algolia/configuration.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ def initialize(app_id, api_key, hosts, client_name, opts = {})
2525
@app_id = app_id
2626
@api_key = api_key
2727
@client_side_validation = opts[:client_side_validation].nil? ? true : opts[:client_side_validation]
28-
@connect_timeout = opts[:connect_timeout] || 2_000
29-
@read_timeout = opts[:read_timeout] || 5_000
30-
@write_timeout = opts[:write_timeout] || 30_000
28+
@connect_timeout = opts[:connect_timeout]
29+
@read_timeout = opts[:read_timeout]
30+
@write_timeout = opts[:write_timeout]
3131
@compression_type = opts[:compression_type] || "none"
3232
@requester = opts[:requester]
3333

34+
puts(@connect_timeout)
35+
puts(@read_timeout)
36+
puts(@write_timeout)
37+
3438
@user_agent = UserAgent.new.add(client_name, VERSION)
3539

3640
if opts[:user_agent_segments]

templates/ruby/api.mustache

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ module {{moduleName}}
3030
region = nil
3131
end
3232

33-
if opts.nil? || opts[:connect_timeout].nil?
34-
opts[:connect_timeout] = {{x-timeouts.server.connect}}
35-
end
36-
37-
if opts.nil? || opts[:read_timeout].nil?
38-
opts[:read_timeout] = {{x-timeouts.server.read}}
39-
end
40-
41-
if opts.nil? || opts[:write_timeout].nil?
42-
opts[:write_timeout] = {{x-timeouts.server.write}}
43-
end
44-
4533
{{^fallbackToAliasHost}}
4634
raise "`region` is required and must be one of the following: #{regions.join(', ')}" if region.nil? || !region.is_a?(String) || !regions.include?(region)
4735
{{/fallbackToAliasHost}}
@@ -70,6 +58,18 @@ module {{moduleName}}
7058
end
7159

7260
def self.create_with_config(config)
61+
if config.connect_timeout.nil? ||config.connect_timeout.empty?
62+
config.connect_timeout = {{x-timeouts.server.connect}}
63+
end
64+
65+
if config.read_timeout.nil? || config.read_timeout.empty?
66+
config.read_timeout = {{x-timeouts.server.read}}
67+
end
68+
69+
if config.write_timeout.nil? || config.write_timeout.empty?
70+
config.write_timeout = {{x-timeouts.server.write}}
71+
end
72+
7373
new(config)
7474
end
7575

0 commit comments

Comments
 (0)