Skip to content

Commit d271ac6

Browse files
Add configuration skipInitialPoll to allow the SDK to be configured without any CDN requests. (FF-2047) (#60)
1 parent 2173a07 commit d271ac6

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/client/eppo-client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export type FlagConfigurationRequestParameters = {
108108
pollAfterSuccessfulInitialization?: boolean;
109109
pollAfterFailedInitialization?: boolean;
110110
throwOnFailedInitialization?: boolean;
111+
skipInitialPoll?: boolean;
111112
};
112113

113114
export default class EppoClient implements IEppoClient {
@@ -181,6 +182,7 @@ export default class EppoClient implements IEppoClient {
181182
this.configurationRequestParameters.pollAfterFailedInitialization ?? false,
182183
errorOnFailedStart:
183184
this.configurationRequestParameters.throwOnFailedInitialization ?? false,
185+
skipInitialPoll: this.configurationRequestParameters.skipInitialPoll ?? false,
184186
},
185187
);
186188

src/poller.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ describe('poller', () => {
2222
});
2323

2424
describe('initial startup', () => {
25+
it('skips initial poll if configured to do so', async () => {
26+
const poller = initPoller(testIntervalMs, noOpCallback, { skipInitialPoll: true });
27+
await poller.start();
28+
td.verify(noOpCallback(), { times: 0 });
29+
});
30+
2531
it('retries startup poll within same promise', async () => {
2632
const pollerRetries = 3;
2733
let callCount = 0;

src/poller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function initPoller(
2323
pollAfterSuccessfulStart?: boolean;
2424
errorOnFailedStart?: boolean;
2525
pollAfterFailedStart?: boolean;
26+
skipInitialPoll?: boolean;
2627
},
2728
): IPoller {
2829
let stopped = false;
@@ -34,8 +35,9 @@ export default function initPoller(
3435
const start = async () => {
3536
stopped = false;
3637
let startRequestSuccess = false;
37-
let startAttemptsRemaining =
38-
1 + (options?.maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES);
38+
let startAttemptsRemaining = options?.skipInitialPoll
39+
? 0
40+
: 1 + (options?.maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES);
3941

4042
let startErrorToThrow = null;
4143

0 commit comments

Comments
 (0)