diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2e9aece..b387c07 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM denoland/deno:2.4.0 +FROM denoland/deno:2.4.1 # Install tools RUN apt-get update && \ diff --git a/README.md b/README.md index 800c131..9056a3a 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ You can also activate features such as local and silent mode: ```ts const local = true; -const static = true; +const freeze = true; const logger = true; const snapshotLocation = './snapshot/'; const snapshotAutoUpdateInterval = 3; @@ -85,7 +85,7 @@ const switcher = Client.getSwitcher(); ``` - **local**: If activated, the client will only fetch the configuration inside your snapshot file. The default value is 'false' -- **static**: If activated, the client will not perform any API calls and will only use the in-memory snapshot. The default value is 'false' +- **freeze**: If activated, prevents the execution of background cache update when using throttle. The default value is 'false' - **logger**: If activated, it is possible to retrieve the last results from a given Switcher key using Client.getLogger('KEY') - **snapshotLocation**: Location of snapshot files - **snapshotAutoUpdateInterval**: Enable Snapshot Auto Update given an interval in seconds (default: 0 disabled) diff --git a/deno.jsonc b/deno.jsonc index 70e3747..2617681 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,6 +1,6 @@ { "name": "@switcherapi/switcher-client-deno", - "version": "2.3.0", + "version": "2.3.1", "description": "Switcher4Deno is a Feature Flag Deno Client SDK for Switcher API", "tasks": { "cache-reload": "deno cache --reload --lock=deno.lock mod.ts", diff --git a/sonar-project.properties b/sonar-project.properties index 34b36d9..221525c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=switcherapi_switcher-client-deno sonar.projectName=switcher-client-deno sonar.organization=switcherapi -sonar.projectVersion=2.3.0 +sonar.projectVersion=2.3.1 sonar.javascript.lcov.reportPaths=coverage/report.lcov diff --git a/src/client.ts b/src/client.ts index 7542e6a..543da86 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3,11 +3,11 @@ import * as util from './lib/utils/index.ts'; import Bypasser from './lib/bypasser/index.ts'; import { DEFAULT_ENVIRONMENT, + DEFAULT_FREEZE, DEFAULT_LOCAL, DEFAULT_LOGGER, DEFAULT_REGEX_MAX_BLACKLISTED, DEFAULT_REGEX_MAX_TIME_LIMIT, - DEFAULT_STATIC, DEFAULT_TEST_MODE, SWITCHER_OPTIONS, } from './lib/constants.ts'; @@ -63,7 +63,7 @@ export class Client { snapshotAutoUpdateInterval: 0, snapshotLocation: options?.snapshotLocation, local: util.get(options?.local, DEFAULT_LOCAL), - static: util.get(options?.static, DEFAULT_STATIC), + freeze: util.get(options?.freeze, DEFAULT_FREEZE), logger: util.get(options?.logger, DEFAULT_LOGGER), }); diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 0b60f77..54bfea1 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,6 +1,6 @@ export const DEFAULT_ENVIRONMENT = 'default'; export const DEFAULT_LOCAL = false; -export const DEFAULT_STATIC = false; +export const DEFAULT_FREEZE = false; export const DEFAULT_LOGGER = false; export const DEFAULT_TEST_MODE = false; export const DEFAULT_REGEX_MAX_BLACKLISTED = 50; diff --git a/src/lib/globals/globalOptions.ts b/src/lib/globals/globalOptions.ts index 4a3c812..830a975 100644 --- a/src/lib/globals/globalOptions.ts +++ b/src/lib/globals/globalOptions.ts @@ -20,8 +20,8 @@ export class GlobalOptions { return this.options.local; } - static get static() { - return this.options.static; + static get freeze() { + return this.options.freeze; } static get logger() { diff --git a/src/switcher.ts b/src/switcher.ts index f70e4d3..9525fb6 100644 --- a/src/switcher.ts +++ b/src/switcher.ts @@ -252,7 +252,7 @@ export class Switcher extends SwitcherBuilder implements SwitcherRequest { private _tryCachedResult(): SwitcherResult | boolean | undefined { if (this._hasThrottle()) { - if (!GlobalOptions.static) { + if (!GlobalOptions.freeze) { this.scheduleBackgroundRefresh(); } diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 06a6208..c7be365 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -44,13 +44,11 @@ export type SwitcherOptions = { local?: boolean; /** - * When enabled it will always use in-memory cached results - * - * This option prevents the scheduling of background updates to improve overall performance + * This option prevents the execution of background cache update when using throttle * * Use Client.clearLogger() to reset the in-memory cache if snapshot are renewed */ - static?: boolean; + freeze?: boolean; /** * When enabled it allows inspecting the result details with Client.getLogger(key) diff --git a/tests/switcher-client.test.ts b/tests/switcher-client.test.ts index 70ca0cc..7913879 100644 --- a/tests/switcher-client.test.ts +++ b/tests/switcher-client.test.ts @@ -340,10 +340,10 @@ describe('E2E test - Client local from cache:', function () { assertEquals((result as SwitcherResult).metadata || {}, {}); }); - it('should get response from cache when static mode is enabled', testSettings, async function () { + it('should get response from cache when freeze mode is enabled', testSettings, async function () { // given Client.buildContext({ url, apiKey, domain, component, environment }, { - snapshotLocation, local: true, static: true + snapshotLocation, local: true, freeze: true }); await Client.loadSnapshot();