Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client/eppo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export type FlagConfigurationRequestParameters = {
pollAfterSuccessfulInitialization?: boolean;
pollAfterFailedInitialization?: boolean;
throwOnFailedInitialization?: boolean;
skipInitialPoll?: boolean;
};

export default class EppoClient implements IEppoClient {
Expand Down Expand Up @@ -181,6 +182,7 @@ export default class EppoClient implements IEppoClient {
this.configurationRequestParameters.pollAfterFailedInitialization ?? false,
errorOnFailedStart:
this.configurationRequestParameters.throwOnFailedInitialization ?? false,
skipInitialPoll: this.configurationRequestParameters.skipInitialPoll ?? false,
},
);

Expand Down
6 changes: 6 additions & 0 deletions src/poller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('poller', () => {
});

describe('initial startup', () => {
it('skips initial poll if configured to do so', async () => {
const poller = initPoller(testIntervalMs, noOpCallback, { skipInitialPoll: true });
await poller.start();
td.verify(noOpCallback(), { times: 0 });
});

it('retries startup poll within same promise', async () => {
const pollerRetries = 3;
let callCount = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function initPoller(
pollAfterSuccessfulStart?: boolean;
errorOnFailedStart?: boolean;
pollAfterFailedStart?: boolean;
skipInitialPoll?: boolean;
},
): IPoller {
let stopped = false;
Expand All @@ -34,8 +35,9 @@ export default function initPoller(
const start = async () => {
stopped = false;
let startRequestSuccess = false;
let startAttemptsRemaining =
1 + (options?.maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES);
let startAttemptsRemaining = options?.skipInitialPoll
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice way to do it

? 0
: 1 + (options?.maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES);

let startErrorToThrow = null;

Expand Down