Skip to content

Commit 2e17ec6

Browse files
authored
fix(javascript): rename timedout and timeouted to timed out (#616)
1 parent f8aabf1 commit 2e17ec6

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

clients/algoliasearch-client-javascript/packages/client-common/src/createRetryablePromise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function createRetryablePromise<TResponse>({
3030
} else if (retryCount + 1 >= maxTrial) {
3131
reject(
3232
new Error(
33-
`The maximum number of trials exceeded. (${
33+
`The maximum number of retries exceeded. (${
3434
retryCount + 1
3535
}/${maxTrial})`
3636
)

clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createStatefulHost.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export function createStatefulHost(
1414
return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
1515
}
1616

17-
function isTimedout(): boolean {
18-
return status === 'timedout' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
17+
function isTimedOut(): boolean {
18+
return (
19+
status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY
20+
);
1921
}
2022

21-
return { ...host, status, lastUpdate, isUp, isTimedout };
23+
return { ...host, status, lastUpdate, isUp, isTimedOut };
2224
}

clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export function createTransporter({
5353
})
5454
);
5555
const hostsUp = statefulHosts.filter((host) => host.isUp());
56-
const hostsTimeouted = statefulHosts.filter((host) => host.isTimedout());
56+
const hostsTimedOut = statefulHosts.filter((host) => host.isTimedOut());
5757

58-
// Note, we put the hosts that previously timeouted on the end of the list.
59-
const hostsAvailable = [...hostsUp, ...hostsTimeouted];
58+
// Note, we put the hosts that previously timed out on the end of the list.
59+
const hostsAvailable = [...hostsUp, ...hostsTimedOut];
6060
const compatibleHostsAvailable =
6161
hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
6262

@@ -65,19 +65,19 @@ export function createTransporter({
6565
getTimeout(timeoutsCount: number, baseTimeout: number): number {
6666
/**
6767
* Imagine that you have 4 hosts, if timeouts will increase
68-
* on the following way: 1 (timeouted) > 4 (timeouted) > 5 (200).
68+
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
6969
*
7070
* Note that, the very next request, we start from the previous timeout.
7171
*
72-
* 5 (timeouted) > 6 (timeouted) > 7 ...
72+
* 5 (timed out) > 6 (timed out) > 7 ...
7373
*
7474
* This strategy may need to be reviewed, but is the strategy on the our
7575
* current v3 version.
7676
*/
7777
const timeoutMultiplier =
78-
hostsTimeouted.length === 0 && timeoutsCount === 0
78+
hostsTimedOut.length === 0 && timeoutsCount === 0
7979
? 1
80-
: hostsTimeouted.length + 3 + timeoutsCount;
80+
: hostsTimedOut.length + 3 + timeoutsCount;
8181

8282
return timeoutMultiplier * baseTimeout;
8383
},
@@ -204,7 +204,7 @@ export function createTransporter({
204204
*/
205205
await hostsCache.set(
206206
host,
207-
createStatefulHost(host, response.isTimedOut ? 'timedout' : 'down')
207+
createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down')
208208
);
209209

210210
return retry(retryableHosts, getTimeout);

clients/algoliasearch-client-javascript/packages/client-common/src/types/Host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export type Host = {
55
};
66

77
export type StatefulHost = Host & {
8-
status: 'down' | 'timedout' | 'up';
8+
status: 'down' | 'timed out' | 'up';
99
lastUpdate: number;
1010
isUp: () => boolean;
11-
isTimedout: () => boolean;
11+
isTimedOut: () => boolean;
1212
};

0 commit comments

Comments
 (0)