Skip to content

Commit 195b1b1

Browse files
Add factory destroy method
1 parent 0591c35 commit 195b1b1

File tree

6 files changed

+28
-62
lines changed

6 files changed

+28
-62
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio",
3-
"version": "10.28.1-rc.1",
3+
"version": "10.28.1-rc.2",
44
"description": "Split SDK",
55
"files": [
66
"README.md",
@@ -40,7 +40,7 @@
4040
"node": ">=6"
4141
},
4242
"dependencies": {
43-
"@splitsoftware/splitio-commons": "1.17.1-rc.0",
43+
"@splitsoftware/splitio-commons": "1.17.1-rc.1",
4444
"@types/google.analytics": "0.0.40",
4545
"@types/ioredis": "^4.28.0",
4646
"bloom-filters": "^3.0.0",

src/__tests__/browserSuites/readiness.spec.js

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,7 @@ export default function (fetchMock, assert) {
209209
t.equal(getMembershipsHits(), 4 * CLIENTS_COUNT - 1, 'It should have not tried to synchronize segments again after the last update that left us in a no segment state.');
210210
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');
211211

212-
Promise.all([
213-
client2.destroy(),
214-
client3.destroy(),
215-
client.destroy()
216-
]).then(() => { t.end(); });
217-
212+
splitio.destroy().then(() => { t.end(); });
218213
}, 10000);
219214
}, 0);
220215
});
@@ -293,12 +288,7 @@ export default function (fetchMock, assert) {
293288
t.equal(getMembershipsHits(), 4 * CLIENTS_COUNT - 1, 'It should have not tried to synchronize segments again after the last update that left us in a no segment state.');
294289
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');
295290

296-
Promise.all([
297-
client2.destroy(),
298-
client3.destroy(),
299-
client.destroy()
300-
]).then(() => { t.end(); });
301-
291+
splitio.destroy().then(() => { t.end(); });
302292
}, 10000);
303293
}, 0);
304294
});
@@ -373,12 +363,7 @@ export default function (fetchMock, assert) {
373363
t.equal(getMembershipsHits(), 6 * CLIENTS_COUNT - 1, 'It should keep the producer synchronizing periodically..');
374364
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');
375365

376-
Promise.all([
377-
client2.destroy(),
378-
client3.destroy(),
379-
client.destroy()
380-
]).then(() => { t.end(); });
381-
366+
splitio.destroy().then(() => { t.end(); });
382367
}, 3000);
383368
}, 0);
384369
});
@@ -442,12 +427,7 @@ export default function (fetchMock, assert) {
442427
setTimeout(() => {
443428
t.equal(getMembershipsHits(), 6 * CLIENTS_COUNT, 'It should keep the producer synchronizing periodically..');
444429

445-
Promise.all([
446-
client2.destroy(),
447-
client3.destroy(),
448-
client.destroy()
449-
]).then(() => { t.end(); });
450-
430+
splitio.destroy().then(() => { t.end(); });
451431
}, 3000);
452432
}, 0);
453433
});
@@ -494,11 +474,7 @@ export default function (fetchMock, assert) {
494474

495475
setTimeout(() => {
496476
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and keep syncing afterwards.');
497-
Promise.all([
498-
client2.destroy(),
499-
client3.destroy(),
500-
client.destroy()
501-
]).then(() => { t.end(); });
477+
splitio.destroy().then(() => { t.end(); });
502478
}, 2500);
503479
});
504480
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
@@ -541,11 +517,7 @@ export default function (fetchMock, assert) {
541517

542518
setTimeout(() => {
543519
t.equal(getMembershipsHits(), 1 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt but stopped syncing afterwards');
544-
Promise.all([
545-
client2.destroy(),
546-
client3.destroy(),
547-
client.destroy()
548-
]).then(() => { t.end(); });
520+
splitio.destroy().then(() => { t.end(); });
549521
}, 4500);
550522
});
551523
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
@@ -592,11 +564,7 @@ export default function (fetchMock, assert) {
592564
t.ok(delay >= membershipsEndpointDelay, 'It should not be ready without waiting for memberships, when we start from cache it might be stale.');
593565
setTimeout(() => {
594566
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt but stopped syncing afterwards');
595-
Promise.all([
596-
client2.destroy(),
597-
client3.destroy(),
598-
client.destroy()
599-
]).then(() => { t.end(); });
567+
splitio.destroy().then(() => { t.end(); });
600568
}, 3000);
601569
});
602570
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
@@ -639,11 +607,7 @@ export default function (fetchMock, assert) {
639607

640608
setTimeout(() => {
641609
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and kept syncing afterwards');
642-
Promise.all([
643-
client2.destroy(),
644-
client3.destroy(),
645-
client.destroy()
646-
]).then(() => { t.end(); });
610+
splitio.destroy().then(() => { t.end(); });
647611
}, 3000);
648612
});
649613
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
@@ -689,11 +653,7 @@ export default function (fetchMock, assert) {
689653

690654
setTimeout(() => {
691655
t.equal(getMembershipsHits(), 1 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and stopped syncing afterwards');
692-
Promise.all([
693-
client2.destroy(),
694-
client3.destroy(),
695-
client.destroy()
696-
]).then(() => { t.end(); });
656+
splitio.destroy().then(() => { t.end(); });
697657
}, 3000);
698658
});
699659
client.once(client.Event.SDK_READY_TIMED_OUT, () => {

src/__tests__/nodeSuites/readiness.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function (fetchMock, assert) {
4949
try {
5050
await client.ready();
5151
} catch (e) {
52-
await client.destroy();
52+
await splitio.destroy();
5353
t.end();
5454
}
5555
});

src/settings/defaults/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const packageVersion = '10.28.1-rc.1';
1+
export const packageVersion = '10.28.1-rc.2';

types/splitio.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ interface IBasicSDK {
491491
* @property Logger
492492
*/
493493
Logger: ILoggerAPI
494+
/**
495+
* Destroys all the clients created by this factory.
496+
* @function destroy
497+
* @returns {Promise<void>}
498+
*/
499+
destroy(): Promise<void>
494500
}
495501
/****** Exposed namespace ******/
496502
/**

0 commit comments

Comments
 (0)