Skip to content

Commit

Permalink
feat: create offlinePrecomputedInit (#117)
Browse files Browse the repository at this point in the history
* Create offlinePrecomputedInit method

* Adjust config init format to have a precompute object

* v3.9.0

* Bump minor version

* Test for offlinePrecomputedInit

* Fix tests

* Update common version

* Docs update

* Update offline precomputed init to use the configuration wire format

* Remove unused IPrecompute import

* Add a todo comment

* Delete ds store

* Update paths to test files

* Change test data branch back to main

* Fix tests

* Change test data branch back to main

* v3.9.0

* v3.9.0-alpha.0

* Update lock file

* Update to use constructor instead of setters

* Update js sdk common dependency

* Update common sdk dependency to 4.8.0-alpha.1

* Comply with throwOnFailedInitialization

* Remove unneeded reset the static instance before each test

* Make documentation consistent with the interface

* Remove unnecessary casting to Attribute

* Don't include logger prefix in thrown error

* Add a shutdown function and test

* Remove comment

* v3.9.2-alpha.0

* Remove application logger input

* Fix test
  • Loading branch information
sameerank authored Jan 11, 2025
1 parent 1592e91 commit b55bfe2
Show file tree
Hide file tree
Showing 19 changed files with 503 additions and 125 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test-data:
mkdir -p $(tempDir)
git clone -b ${branchName} --depth 1 --single-branch ${githubRepoLink} ${gitDataDir}
cp -r ${gitDataDir}ufc ${testDataDir}
cp -r ${gitDataDir}configuration-wire ${testDataDir}
rm -rf ${tempDir}

## prepare
Expand All @@ -49,4 +50,4 @@ prepare: test-data
## test
.PHONY: test
test: test test-data
yarn test:unit
yarn test:unit
1 change: 1 addition & 0 deletions docs/js-client-sdk.iclientconfig.eventingestionconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ eventIngestionConfig?: {
maxRetryDelayMs?: number;
maxRetries?: number;
batchSize?: number;
maxQueueSize?: number;
};
```
2 changes: 1 addition & 1 deletion docs/js-client-sdk.iclientconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Description
</td><td>
{ deliveryIntervalMs?: number; retryIntervalMs?: number; maxRetryDelayMs?: number; maxRetries?: number; batchSize?: number; }
{ deliveryIntervalMs?: number; retryIntervalMs?: number; maxRetryDelayMs?: number; maxRetries?: number; batchSize?: number; maxQueueSize?: number; }
</td><td>
Expand Down
25 changes: 2 additions & 23 deletions docs/js-client-sdk.iprecomputedclientconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,19 @@ Description
</th></tr></thead>
<tbody><tr><td>
[subjectAttributes?](./js-client-sdk.iprecomputedclientconfig.subjectattributes.md)
[precompute](./js-client-sdk.iprecomputedclientconfig.precompute.md)
</td><td>
</td><td>
Record&lt;string, AttributeType&gt;
IPrecompute
</td><td>
_(Optional)_ Subject attributes to use for precomputed flag assignments.
</td></tr>
<tr><td>
[subjectKey](./js-client-sdk.iprecomputedclientconfig.subjectkey.md)
</td><td>
</td><td>
string
</td><td>
Subject key to use for precomputed flag assignments.
</td></tr>
</tbody></table>
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfig](./js-client-sdk.iprecomputedclientconfig.md) &gt; [subjectKey](./js-client-sdk.iprecomputedclientconfig.subjectkey.md)
[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfig](./js-client-sdk.iprecomputedclientconfig.md) &gt; [precompute](./js-client-sdk.iprecomputedclientconfig.precompute.md)

## IPrecomputedClientConfig.subjectKey property

Subject key to use for precomputed flag assignments.
## IPrecomputedClientConfig.precompute property

**Signature:**

```typescript
subjectKey: string;
precompute: IPrecompute;
```
13 changes: 0 additions & 13 deletions docs/js-client-sdk.iprecomputedclientconfig.subjectattributes.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md) &gt; [assignmentLogger](./js-client-sdk.iprecomputedclientconfigsync.assignmentlogger.md)

## IPrecomputedClientConfigSync.assignmentLogger property

**Signature:**

```typescript
assignmentLogger?: IAssignmentLogger;
```
97 changes: 97 additions & 0 deletions docs/js-client-sdk.iprecomputedclientconfigsync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md)

## IPrecomputedClientConfigSync interface

Configuration parameters for initializing the Eppo precomputed client.

This interface is used for cases where precomputed assignments are available from an external process that can bootstrap the SDK client.

precomputedConfiguration - The configuration as a string to bootstrap the client. assignmentLogger - Optional logger for assignment events. throwOnFailedInitialization - Optional flag to throw an error if initialization fails.

**Signature:**

```typescript
export interface IPrecomputedClientConfigSync
```

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[assignmentLogger?](./js-client-sdk.iprecomputedclientconfigsync.assignmentlogger.md)


</td><td>


</td><td>

IAssignmentLogger


</td><td>

_(Optional)_


</td></tr>
<tr><td>

[precomputedConfiguration](./js-client-sdk.iprecomputedclientconfigsync.precomputedconfiguration.md)


</td><td>


</td><td>

string


</td><td>


</td></tr>
<tr><td>

[throwOnFailedInitialization?](./js-client-sdk.iprecomputedclientconfigsync.throwonfailedinitialization.md)


</td><td>


</td><td>

boolean


</td><td>

_(Optional)_


</td></tr>
</tbody></table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md) &gt; [precomputedConfiguration](./js-client-sdk.iprecomputedclientconfigsync.precomputedconfiguration.md)

## IPrecomputedClientConfigSync.precomputedConfiguration property

**Signature:**

```typescript
precomputedConfiguration: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md) &gt; [throwOnFailedInitialization](./js-client-sdk.iprecomputedclientconfigsync.throwonfailedinitialization.md)

## IPrecomputedClientConfigSync.throwOnFailedInitialization property

**Signature:**

```typescript
throwOnFailedInitialization?: boolean;
```
30 changes: 30 additions & 0 deletions docs/js-client-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ The purpose is for use-cases where the configuration is available from an extern
This method should be called once on application startup.


</td></tr>
<tr><td>

[offlinePrecomputedInit(config)](./js-client-sdk.offlineprecomputedinit.md)


</td><td>

Initializes the Eppo precomputed client with configuration parameters.

The purpose is for use-cases where the precomputed assignments are available from an external process that can bootstrap the SDK.

This method should be called once on application startup.


</td></tr>
<tr><td>

Expand Down Expand Up @@ -197,5 +212,20 @@ Configuration interface for synchronous client initialization.
Configuration for Eppo precomputed client initialization


</td></tr>
<tr><td>

[IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md)


</td><td>

Configuration parameters for initializing the Eppo precomputed client.

This interface is used for cases where precomputed assignments are available from an external process that can bootstrap the SDK client.

precomputedConfiguration - The configuration as a string to bootstrap the client. assignmentLogger - Optional logger for assignment events. throwOnFailedInitialization - Optional flag to throw an error if initialization fails.


</td></tr>
</tbody></table>
59 changes: 59 additions & 0 deletions docs/js-client-sdk.offlineprecomputedinit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [offlinePrecomputedInit](./js-client-sdk.offlineprecomputedinit.md)

## offlinePrecomputedInit() function

Initializes the Eppo precomputed client with configuration parameters.

The purpose is for use-cases where the precomputed assignments are available from an external process that can bootstrap the SDK.

This method should be called once on application startup.

**Signature:**

```typescript
export declare function offlinePrecomputedInit(config: IPrecomputedClientConfigSync): EppoPrecomputedClient;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

config


</td><td>

[IPrecomputedClientConfigSync](./js-client-sdk.iprecomputedclientconfigsync.md)


</td><td>

precomputed client configuration


</td></tr>
</tbody></table>
**Returns:**

EppoPrecomputedClient

a singleton precomputed client instance

20 changes: 18 additions & 2 deletions js-client-sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface IClientConfig extends IBaseRequestConfig {
maxRetryDelayMs?: number;
maxRetries?: number;
batchSize?: number;
maxQueueSize?: number;
};
forceReinitialize?: boolean;
maxCacheAgeSeconds?: number;
Expand Down Expand Up @@ -149,15 +150,30 @@ export function init(config: IClientConfig): Promise<EppoClient>;

// @public
export interface IPrecomputedClientConfig extends IBaseRequestConfig {
subjectAttributes?: Record<string, AttributeType>;
subjectKey: string;
// Warning: (ae-forgotten-export) The symbol "IPrecompute" needs to be exported by the entry point index.d.ts
//
// (undocumented)
precompute: IPrecompute;
}

// @public
export interface IPrecomputedClientConfigSync {
// (undocumented)
assignmentLogger?: IAssignmentLogger;
// (undocumented)
precomputedConfiguration: string;
// (undocumented)
throwOnFailedInitialization?: boolean;
}

export { ObfuscatedFlag }

// @public
export function offlineInit(config: IClientConfigSync): EppoClient;

// @public
export function offlinePrecomputedInit(config: IPrecomputedClientConfigSync): EppoPrecomputedClient;

// @public
export function precomputedInit(config: IPrecomputedClientConfig): Promise<EppoPrecomputedClient>;

Expand Down
Loading

0 comments on commit b55bfe2

Please sign in to comment.