Skip to content

Commit 0e7af04

Browse files
algolia-botmillotp
andcommitted
fix(clients): move default timeouts to the constructor (generated)
algolia/api-clients-automation#5443 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 88c3d3e commit 0e7af04

11 files changed

+142
-142
lines changed

lib/algolia/api/abtesting_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "Abtesting", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/abtesting_v3_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "AbtestingV3", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/analytics_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "Analytics", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/composition_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -27,22 +39,10 @@ def self.create(app_id, api_key, opts = {})
2739
.shuffle
2840

2941
config = Algolia::Configuration.new(app_id, api_key, hosts, "Composition", opts)
30-
create_with_config(config)
42+
new(config)
3143
end
3244

3345
def self.create_with_config(config)
34-
if config.connect_timeout.nil?
35-
config.connect_timeout = 2000
36-
end
37-
38-
if config.read_timeout.nil?
39-
config.read_timeout = 5000
40-
end
41-
42-
if config.write_timeout.nil?
43-
config.write_timeout = 30000
44-
end
45-
4646
new(config)
4747
end
4848

lib/algolia/api/ingestion_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 25000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 25000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 25000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "Ingestion", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 25000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 25000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 25000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/insights_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "Insights", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/monitoring_client.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14-
@api_client = Algolia::ApiClient.new(config)
15-
end
16-
17-
def self.create(app_id, api_key, opts = {})
18-
hosts = []
19-
hosts << Transport::StatefulHost.new("status.algolia.com", accept: CallType::READ | CallType::WRITE)
20-
21-
config = Algolia::Configuration.new(app_id, api_key, hosts, "Monitoring", opts)
22-
create_with_config(config)
23-
end
24-
25-
def self.create_with_config(config)
2614
if config.connect_timeout.nil?
2715
config.connect_timeout = 2000
2816
end
@@ -35,6 +23,18 @@ def self.create_with_config(config)
3523
config.write_timeout = 30000
3624
end
3725

26+
@api_client = Algolia::ApiClient.new(config)
27+
end
28+
29+
def self.create(app_id, api_key, opts = {})
30+
hosts = []
31+
hosts << Transport::StatefulHost.new("status.algolia.com", accept: CallType::READ | CallType::WRITE)
32+
33+
config = Algolia::Configuration.new(app_id, api_key, hosts, "Monitoring", opts)
34+
new(config)
35+
end
36+
37+
def self.create_with_config(config)
3838
new(config)
3939
end
4040

lib/algolia/api/personalization_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "Personalization", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

lib/algolia/api/query_suggestions_client.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ def initialize(config = nil)
1111
raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
1212
raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""
1313

14+
if config.connect_timeout.nil?
15+
config.connect_timeout = 2000
16+
end
17+
18+
if config.read_timeout.nil?
19+
config.read_timeout = 5000
20+
end
21+
22+
if config.write_timeout.nil?
23+
config.write_timeout = 30000
24+
end
25+
1426
@api_client = Algolia::ApiClient.new(config)
1527
end
1628

@@ -34,22 +46,10 @@ def self.create(app_id, api_key, region = nil, opts = {})
3446
)
3547

3648
config = Algolia::Configuration.new(app_id, api_key, hosts, "QuerySuggestions", opts)
37-
create_with_config(config)
49+
new(config)
3850
end
3951

4052
def self.create_with_config(config)
41-
if config.connect_timeout.nil?
42-
config.connect_timeout = 2000
43-
end
44-
45-
if config.read_timeout.nil?
46-
config.read_timeout = 5000
47-
end
48-
49-
if config.write_timeout.nil?
50-
config.write_timeout = 30000
51-
end
52-
5353
new(config)
5454
end
5555

0 commit comments

Comments
 (0)