Skip to content

Commit

Permalink
Add factory destroy method
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Sep 20, 2024
1 parent 0591c35 commit 195b1b1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 62 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio",
"version": "10.28.1-rc.1",
"version": "10.28.1-rc.2",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -40,7 +40,7 @@
"node": ">=6"
},
"dependencies": {
"@splitsoftware/splitio-commons": "1.17.1-rc.0",
"@splitsoftware/splitio-commons": "1.17.1-rc.1",
"@types/google.analytics": "0.0.40",
"@types/ioredis": "^4.28.0",
"bloom-filters": "^3.0.0",
Expand Down
58 changes: 9 additions & 49 deletions src/__tests__/browserSuites/readiness.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,7 @@ export default function (fetchMock, assert) {
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.');
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');

Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });

splitio.destroy().then(() => { t.end(); });
}, 10000);
}, 0);
});
Expand Down Expand Up @@ -293,12 +288,7 @@ export default function (fetchMock, assert) {
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.');
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');

Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });

splitio.destroy().then(() => { t.end(); });
}, 10000);
}, 0);
});
Expand Down Expand Up @@ -373,12 +363,7 @@ export default function (fetchMock, assert) {
t.equal(getMembershipsHits(), 6 * CLIENTS_COUNT - 1, 'It should keep the producer synchronizing periodically..');
t.equal(readyCount, CLIENTS_COUNT, 'all clients must be ready');

Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });

splitio.destroy().then(() => { t.end(); });
}, 3000);
}, 0);
});
Expand Down Expand Up @@ -442,12 +427,7 @@ export default function (fetchMock, assert) {
setTimeout(() => {
t.equal(getMembershipsHits(), 6 * CLIENTS_COUNT, 'It should keep the producer synchronizing periodically..');

Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });

splitio.destroy().then(() => { t.end(); });
}, 3000);
}, 0);
});
Expand Down Expand Up @@ -494,11 +474,7 @@ export default function (fetchMock, assert) {

setTimeout(() => {
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and keep syncing afterwards.');
Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });
splitio.destroy().then(() => { t.end(); });
}, 2500);
});
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
Expand Down Expand Up @@ -541,11 +517,7 @@ export default function (fetchMock, assert) {

setTimeout(() => {
t.equal(getMembershipsHits(), 1 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt but stopped syncing afterwards');
Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });
splitio.destroy().then(() => { t.end(); });
}, 4500);
});
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
Expand Down Expand Up @@ -592,11 +564,7 @@ export default function (fetchMock, assert) {
t.ok(delay >= membershipsEndpointDelay, 'It should not be ready without waiting for memberships, when we start from cache it might be stale.');
setTimeout(() => {
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt but stopped syncing afterwards');
Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });
splitio.destroy().then(() => { t.end(); });
}, 3000);
});
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
Expand Down Expand Up @@ -639,11 +607,7 @@ export default function (fetchMock, assert) {

setTimeout(() => {
t.equal(getMembershipsHits(), 3 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and kept syncing afterwards');
Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });
splitio.destroy().then(() => { t.end(); });
}, 3000);
});
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
Expand Down Expand Up @@ -689,11 +653,7 @@ export default function (fetchMock, assert) {

setTimeout(() => {
t.equal(getMembershipsHits(), 1 * CLIENTS_COUNT, 'memberships should had been hit once per client on the first attempt and stopped syncing afterwards');
Promise.all([
client2.destroy(),
client3.destroy(),
client.destroy()
]).then(() => { t.end(); });
splitio.destroy().then(() => { t.end(); });
}, 3000);
});
client.once(client.Event.SDK_READY_TIMED_OUT, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/nodeSuites/readiness.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function (fetchMock, assert) {
try {
await client.ready();
} catch (e) {
await client.destroy();
await splitio.destroy();
t.end();
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaults/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const packageVersion = '10.28.1-rc.1';
export const packageVersion = '10.28.1-rc.2';
6 changes: 6 additions & 0 deletions types/splitio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ interface IBasicSDK {
* @property Logger
*/
Logger: ILoggerAPI
/**
* Destroys all the clients created by this factory.
* @function destroy
* @returns {Promise<void>}
*/
destroy(): Promise<void>
}
/****** Exposed namespace ******/
/**
Expand Down

0 comments on commit 195b1b1

Please sign in to comment.