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: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM denoland/deno:2.4.0
FROM denoland/deno:2.4.1

# Install tools
RUN apt-get update && \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/globals/globalOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/switcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
6 changes: 2 additions & 4 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/switcher-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down