Skip to content

Commit 896b9d0

Browse files
committed
Rename timeout_seconds to connection_timeout_seconds
1 parent 04cba8b commit 896b9d0

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

examples/alias_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'port': '8108',
1010
'protocol': 'http'
1111
}],
12-
'timeout_seconds': 2
12+
'connection_timeout_seconds': 2
1313
})
1414

1515
# Create a collection

examples/collection_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'port': '8108',
1616
'protocol': 'http'
1717
}],
18-
'timeout_seconds': 2
18+
'connection_timeout_seconds': 2
1919
})
2020

2121
# Create a collection

examples/curation_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'port': '8108',
1010
'protocol': 'http'
1111
}],
12-
'timeout_seconds': 2
12+
'connection_timeout_seconds': 2
1313
})
1414

1515
# Create a collection

examples/index_and_search.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99

1010

1111
client = typesense.Client({
12-
'api_key': 'abcd',
12+
'api_key': 'esdSJsadjadskSAksdjsdnasw',
1313
'nodes': [
1414
{
15-
'host': 'localhost',
16-
'port': '8108',
17-
'protocol': 'http'
15+
'host': 'tempest2-1.a1.typesense.net',
16+
'port': '443',
17+
'protocol': 'https'
1818
},
1919
{
20-
'host': 'localhost',
21-
'port': '7108',
22-
'protocol': 'http'
20+
'host': 'tempest2-2.a1.typesense.net',
21+
'port': '443',
22+
'protocol': 'https'
2323
},
2424
{
25-
'host': 'localhost',
26-
'port': '6108',
27-
'protocol': 'http'
25+
'host': 'tempest2-3.a1.typesense.net',
26+
'port': '443',
27+
'protocol': 'https'
2828
}
2929
],
30-
'timeout_seconds': 2
30+
'connection_timeout_seconds': 10
3131
})
3232

3333
schema = {
@@ -55,6 +55,7 @@
5555
for json_line in infile:
5656
book_documents.append(json.loads(json_line))
5757

58+
print('')
5859
print(client.collections['books'].documents.create_many(book_documents))
5960

6061
i = 0

typesense/api_call.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def make_request(self, fn, endpoint, as_json, **kwargs):
8484
if 0 < r.status_code < 500:
8585
node.healthy = True
8686

87-
# We should raise a custom exception if status code is not 200 or 201
88-
if r.status_code not in [200, 201]:
87+
# We should raise a custom exception if status code is not 20X
88+
if 200 <= r.status_code < 300:
8989
error_message = r.json().get('message', 'API error.')
9090
# Raised exception will be caught and retried only if it's a 50X
9191
raise ApiCall.get_exception(r.status_code)(r.status_code, error_message)
@@ -104,16 +104,16 @@ def get(self, endpoint, params=None, as_json=True):
104104
params = params or {}
105105
return self.make_request(requests.get, endpoint, as_json,
106106
params=params,
107-
timeout=self.config.timeout_seconds)
107+
timeout=self.config.connection_timeout_seconds)
108108

109109
def post(self, endpoint, body):
110110
return self.make_request(requests.post, endpoint, True,
111-
data=body, timeout=self.config.timeout_seconds)
111+
data=body, timeout=self.config.connection_timeout_seconds)
112112

113113
def put(self, endpoint, body):
114114
return self.make_request(requests.put, endpoint, True,
115-
data=body, timeout=self.config.timeout_seconds)
115+
data=body, timeout=self.config.connection_timeout_seconds)
116116

117117
def delete(self, endpoint):
118118
return self.make_request(requests.delete, endpoint, True,
119-
timeout=self.config.timeout_seconds)
119+
timeout=self.config.connection_timeout_seconds)

typesense/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, config_dict):
2828
)
2929

3030
self.api_key = config_dict.get('api_key', '')
31-
self.timeout_seconds = config_dict.get('timeout_seconds', 3.0)
31+
self.connection_timeout_seconds = config_dict.get('connection_timeout_seconds', 3.0)
3232
self.num_retries = config_dict.get('num_retries', 3)
3333
self.retry_interval_seconds = config_dict.get('retry_interval_seconds', 1.0)
3434
self.healthcheck_interval_seconds = config_dict.get('healthcheck_interval_seconds', 60)

0 commit comments

Comments
 (0)