Skip to content

Commit 1900fb8

Browse files
authored
feat: pollingIntervalMs config param and latest from common (#75)
1 parent 0fdfd96 commit 1900fb8

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

docs/node-server-sdk.iclientconfig.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IClientConfig
2323
| [numInitialRequestRetries?](./node-server-sdk.iclientconfig.numinitialrequestretries.md) | | number | _(Optional)_ Number of additional times the initial configuration request will be attempted if it fails. This is the request servers typically synchronously wait for completion. A small wait will be done between requests. (Default: 1) |
2424
| [numPollRequestRetries?](./node-server-sdk.iclientconfig.numpollrequestretries.md) | | number | _(Optional)_ Number of additional times polling for updated configurations will be attempted before giving up. Polling is done after a successful initial request. Subsequent attempts are done using an exponential backoff. (Default: 7) |
2525
| [pollAfterFailedInitialization?](./node-server-sdk.iclientconfig.pollafterfailedinitialization.md) | | boolean | _(Optional)_ Poll for new configurations even if the initial configuration request failed. (default: false) |
26+
| [pollingIntervalMs?](./node-server-sdk.iclientconfig.pollingintervalms.md) | | number | _(Optional)_ Amount of time to wait between API calls to refresh configuration data. Default of 30\_000 (30 seconds). |
2627
| [requestTimeoutMs?](./node-server-sdk.iclientconfig.requesttimeoutms.md) | | number | _(Optional)_ \* Timeout in milliseconds for the HTTPS request for the experiment configuration. (Default: 5000) |
2728
| [throwOnFailedInitialization?](./node-server-sdk.iclientconfig.throwonfailedinitialization.md) | | boolean | _(Optional)_ Throw on error if unable to fetch an initial configuration during initialization. (default: true) |
2829

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@eppo/node-server-sdk](./node-server-sdk.md) &gt; [IClientConfig](./node-server-sdk.iclientconfig.md) &gt; [pollingIntervalMs](./node-server-sdk.iclientconfig.pollingintervalms.md)
4+
5+
## IClientConfig.pollingIntervalMs property
6+
7+
Amount of time to wait between API calls to refresh configuration data. Default of 30\_000 (30 seconds).
8+
9+
**Signature:**
10+
11+
```typescript
12+
pollingIntervalMs?: number;
13+
```

node-server-sdk.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface IClientConfig {
3333
numInitialRequestRetries?: number;
3434
numPollRequestRetries?: number;
3535
pollAfterFailedInitialization?: boolean;
36+
pollingIntervalMs?: number;
3637
requestTimeoutMs?: number;
3738
throwOnFailedInitialization?: boolean;
3839
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/node-server-sdk",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"description": "Eppo node server SDK",
55
"main": "dist/index.js",
66
"files": [
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/Eppo-exp/node-server-sdk#readme",
3131
"dependencies": {
32-
"@eppo/js-client-sdk-common": "4.2.0",
32+
"@eppo/js-client-sdk-common": "4.3.0",
3333
"lru-cache": "^10.0.1"
3434
},
3535
"devDependencies": {

src/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727

2828
import { getInstance, IAssignmentEvent, IAssignmentLogger, init } from '.';
2929

30-
const { POLL_INTERVAL_MS, POLL_JITTER_PCT } = constants;
30+
const { DEFAULT_POLL_INTERVAL_MS, POLL_JITTER_PCT } = constants;
3131

3232
describe('EppoClient E2E test', () => {
3333
const mockLogger: IAssignmentLogger = {
@@ -315,7 +315,7 @@ describe('EppoClient E2E test', () => {
315315
});
316316

317317
describe('initialization errors', () => {
318-
const maxRetryDelay = POLL_INTERVAL_MS * POLL_JITTER_PCT;
318+
const maxRetryDelay = DEFAULT_POLL_INTERVAL_MS * POLL_JITTER_PCT;
319319
const mockConfigResponse = {
320320
flags: {
321321
[flagKey]: mockUfcFlagConfig,
@@ -380,7 +380,7 @@ describe('EppoClient E2E test', () => {
380380
);
381381

382382
// Expect no further configuration requests
383-
await jest.advanceTimersByTimeAsync(POLL_INTERVAL_MS);
383+
await jest.advanceTimersByTimeAsync(DEFAULT_POLL_INTERVAL_MS);
384384
expect(callCount).toBe(1);
385385
});
386386

@@ -419,7 +419,7 @@ describe('EppoClient E2E test', () => {
419419
'default-value',
420420
);
421421

422-
await jest.advanceTimersByTimeAsync(POLL_INTERVAL_MS);
422+
await jest.advanceTimersByTimeAsync(DEFAULT_POLL_INTERVAL_MS);
423423

424424
// Expect a new call from poller
425425
expect(callCount).toBe(3);

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export interface IClientConfig {
6565
* Poll for new configurations even if the initial configuration request failed. (default: false)
6666
*/
6767
pollAfterFailedInitialization?: boolean;
68+
69+
/**
70+
* Amount of time to wait between API calls to refresh configuration data. Default of 30_000 (30 seconds).
71+
*/
72+
pollingIntervalMs?: number;
6873
}
6974

7075
export {
@@ -97,6 +102,7 @@ export async function init(config: IClientConfig): Promise<EppoClient> {
97102
numPollRequestRetries: config.numPollRequestRetries ?? undefined,
98103
pollAfterSuccessfulInitialization: true, // For servers, we always want to keep polling for the life of the server
99104
pollAfterFailedInitialization: config.pollAfterFailedInitialization ?? false,
105+
pollingIntervalMs: config.pollingIntervalMs ?? undefined,
100106
throwOnFailedInitialization: config.throwOnFailedInitialization ?? true,
101107
};
102108

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@
460460
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"
461461
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
462462

463-
"@eppo/js-client-sdk-common@4.2.0":
464-
version "4.2.0"
465-
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-4.2.0.tgz#713910bf7c5291300d48b408bced995ae00e2834"
466-
integrity sha512-DzT3q1jwpb8yEgKLtPzCxaW6X+rUmYuX5jnGqPzLM2WDlfZ0rkUdDqBt9lzw76DkSZu+C7dpzHcH9EnWuDms8w==
463+
"@eppo/js-client-sdk-common@4.3.0":
464+
version "4.3.0"
465+
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-4.3.0.tgz#66c0e5904091ac1a9c2bc3bf4017637b13404ce8"
466+
integrity sha512-ur270vCZjUuKuEohF1vH7yh1MBxtDbVcduCJzJmJ6m7kjoyvqNPzG/+lYPEol6Bpr9wV42ciIB+A1cYeNZ7gSA==
467467
dependencies:
468468
js-base64 "^3.7.7"
469469
md5 "^2.3.0"

0 commit comments

Comments
 (0)