Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade edgekv bundled files to 0.6.3 #610

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LDLogger } from '@launchdarkly/js-server-sdk-common';

import { EdgeKV } from '../../src/edgekv/edgekv';
import EdgeKVProvider from '../../src/edgekv/edgeKVProvider';

Expand All @@ -11,14 +13,21 @@ const NAMESPACE = 'namespace';
const GROUP = 'group';

describe('EdgeKVProvider', () => {
let logger: LDLogger;
beforeEach(() => {
mockEdgeKV.mockImplementation(() => ({
getText: jest.fn().mockResolvedValue('some-text'),
}));
logger = {
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
});

it('get string from edgeKV', async () => {
const edgeKVProvider = new EdgeKVProvider({ namespace: NAMESPACE, group: GROUP });
const edgeKVProvider = new EdgeKVProvider({ namespace: NAMESPACE, group: GROUP, logger });
expect(await edgeKVProvider.get('rootKey')).toEqual('some-text');
});

Expand All @@ -28,7 +37,7 @@ describe('EdgeKVProvider', () => {
getText: jest.fn().mockRejectedValueOnce(expectedError),
}));

const edgeKVProvider = new EdgeKVProvider({ namespace: NAMESPACE, group: GROUP });
const edgeKVProvider = new EdgeKVProvider({ namespace: NAMESPACE, group: GROUP, logger });
const result = await edgeKVProvider.get('rootKey');
expect(result).toBe(undefined);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/akamai-edgekv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchdarkly/akamai-server-edgekv-sdk",
"version": "1.1.16",
"version": "1.1.17-beta.1",
"description": "Akamai LaunchDarkly EdgeWorker SDK for EdgeKV feature store",
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/akamai-edgekv",
"repository": {
Expand Down
8 changes: 6 additions & 2 deletions packages/sdk/akamai-edgekv/src/edgekv/edgeKVProvider.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { EdgeProvider } from '@launchdarkly/akamai-edgeworker-sdk-common';
import { LDLogger } from '@launchdarkly/js-server-sdk-common';

import { EdgeKV } from './edgekv';

type EdgeKVProviderParams = {
namespace: string;
group: string;
logger: LDLogger;
};

export default class EdgeKVProvider implements EdgeProvider {
private edgeKv: EdgeKV;
private logger: LDLogger;

constructor({ namespace, group }: EdgeKVProviderParams) {
constructor({ namespace, group, logger }: EdgeKVProviderParams) {
this.edgeKv = new EdgeKV({ namespace, group } as any);
this.logger = logger;
}

async get(rootKey: string): Promise<string | null | undefined> {
try {
return await this.edgeKv.getText({ item: rootKey } as any);
} catch (e) {
/* empty */
this.logger?.error(`Error getting value from EdgeKV: ${e}`);
}
return undefined;
}
Expand Down
Loading
Loading