Skip to content

Commit 0578bee

Browse files
authored
fix(clients): move default timeouts to the constructor (#5443)
1 parent 24895bb commit 0578bee

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

templates/ruby/api.mustache

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ module {{moduleName}}
1717
raise '`app_id` is missing.' if config.app_id.nil? || config.app_id == ''
1818
raise '`api_key` is missing.' if config.api_key.nil? || config.api_key == ''
1919

20+
if config.connect_timeout.nil?
21+
config.connect_timeout = {{x-timeouts.server.connect}}
22+
end
23+
24+
if config.read_timeout.nil?
25+
config.read_timeout = {{x-timeouts.server.read}}
26+
end
27+
28+
if config.write_timeout.nil?
29+
config.write_timeout = {{x-timeouts.server.write}}
30+
end
31+
2032
@api_client = Algolia::ApiClient.new(config)
2133
end
2234

@@ -54,22 +66,10 @@ module {{moduleName}}
5466
{{/hostsWithoutVariables.size}}
5567

5668
config = Algolia::Configuration.new(app_id, api_key, hosts, '{{{baseName}}}', opts)
57-
create_with_config(config)
69+
new(config)
5870
end
5971

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

@@ -196,4 +196,4 @@ module {{moduleName}}
196196
{{/isSearchClient}}
197197
end
198198
{{/operations}}
199-
end
199+
end

0 commit comments

Comments
 (0)