Skip to content

Commit 8c74a9e

Browse files
docs: document timeout configuration option (#135)
The timeout option already works but was never documented. Add a section to the README showing usage for both Client and APIClient. Fixes #105
1 parent 194307f commit 8c74a9e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ $customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", regi
6060

6161
`region` is optional and takes one of two values—`US` or `EU`. If you do not specify your region, we assume that your account is based in the US (`US`). If your account is based in the EU and you do not provide the correct region (`EU`), we'll route requests to our EU data centers accordingly, however this may cause data to be logged in the US.
6262

63+
#### Timeouts
64+
65+
Both clients accept a `timeout` option (in seconds) that controls the HTTP connect and read timeouts. The default is 10 seconds.
66+
67+
```ruby
68+
# Track API client with a 3-second timeout
69+
$customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", timeout: 3)
70+
71+
# Transactional API client with a 3-second timeout
72+
client = Customerio::APIClient.new("your API key", timeout: 3)
73+
```
74+
75+
When a request exceeds the timeout, Ruby raises `Net::OpenTimeout` (connection phase) or `Net::ReadTimeout` (waiting for response). You can rescue both:
76+
77+
```ruby
78+
begin
79+
$customerio.identify(id: 5, email: "person@example.com")
80+
rescue Net::OpenTimeout, Net::ReadTimeout => e
81+
# handle timeout
82+
end
83+
```
84+
6385
### Identify logged in customers
6486

6587
Tracking data of logged in customers is a key part of [Customer.io](https://customer.io). In order to

0 commit comments

Comments
 (0)