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: adds datasource status to sdk-client #590

Merged
merged 23 commits into from
Sep 30, 2024

Conversation

tanderson-ld
Copy link
Contributor

@tanderson-ld tanderson-ld commented Sep 23, 2024

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

SDK-170

Describe the solution you've provided

Adds DataSourceStatusManager.
Refactors data source errors into common.
Adds DataSourceErrorKind to classify errors so manager can track state.

@tanderson-ld tanderson-ld requested a review from a team as a code owner September 23, 2024 17:30
this.name = 'LaunchDarklyStreamingError';
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: These moved to datasource/errors.ts

Copy link
Contributor Author

@tanderson-ld tanderson-ld Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Majority of content for handling in this file is from LDClientImpl


handlePollingError(error: LDPollingError) {
this.statusManager.setError(error.kind, error.message, error.status, error.recoverable);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: If there is a better way to handle the mapping of StreamingError.code and PollingError.status to status I can unify these functions.

export type PollingErrorHandler = (err: LDPollingError) => void;
// TODO: revisit usage of internal and figure out best practice
const { DataSourceErrorKind, LDPollingError } = internal;
export type PollingErrorHandler = (err: internal.LDPollingError) => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Please provide thoughts on internal import usage here.

@@ -172,64 +170,6 @@ export default class LDClientImpl implements LDClient {
return this.checkedContext;
}

private createStreamListeners(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: This was unused.

/* eslint-disable max-classes-per-file */
import { DataSourceErrorKind } from './DataSourceErrorKinds';

export class LDFileDataSourceError extends Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors are not intended to be internal. In that the internal package should only be used by SDK implementations, but instance of LDPollingError theoretically is something you could do in an application. Maybe we don't want that, but this one is maybe breaking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not expected to be constructed outside though. That part is likely fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started fixing this, but running into some import/export configuration issue. Pushed most recent commit before having to leave for flight.

@@ -256,8 +251,8 @@ describe('sdk-client storage', () => {
JSON.stringify(putResponse),
);

expect(emitter.emit).toHaveBeenNthCalledWith(1, 'change', context, defaultFlagKeys);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may need some explanation on these changes also, as the ordering of events mattered and that isn't tested anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that too. I can go through and get them all to be passing, but I don’t think there is any specification around when a change event should come out vs when a dataSourceStatus change should come out and that is leading to them all breaking as I added dataSourceStatus events.

Perhaps an improved way could be to filter to just “change” and then do positional checking on the filtered output.

@@ -30,4 +31,4 @@ export { DataSourcePaths } from './streaming';
export { BaseDataManager } from './DataManager';
export { Requestor };

export { LDClientImpl, LDClientInternalOptions };
export { DataSourceStatus, LDClientImpl, LDClientInternalOptions };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add DataSourceState, DataSourceStatusErrorInfo, and DataSourceErrorKind

@kinyoklion kinyoklion merged commit 6f26204 into main Sep 30, 2024
22 checks passed
@kinyoklion kinyoklion deleted the ta/sc-249239/data-source-status-rebase branch September 30, 2024 21:31
@github-actions github-actions bot mentioned this pull request Sep 30, 2024
kinyoklion pushed a commit that referenced this pull request Oct 9, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>akamai-edgeworker-sdk-common: 1.2.1</summary>

##
[1.2.1](akamai-edgeworker-sdk-common-v1.2.0...akamai-edgeworker-sdk-common-v1.2.1)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from ^2.7.0 to ^2.8.0
</details>

<details><summary>akamai-server-base-sdk: 2.1.17</summary>

##
[2.1.17](akamai-server-base-sdk-v2.1.16...akamai-server-base-sdk-v2.1.17)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.2.0 to
^1.2.1
    * @launchdarkly/js-server-sdk-common bumped from ^2.7.0 to ^2.8.0
</details>

<details><summary>akamai-server-edgekv-sdk: 1.1.17</summary>

##
[1.1.17](akamai-server-edgekv-sdk-v1.1.16...akamai-server-edgekv-sdk-v1.1.17)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
* @launchdarkly/akamai-edgeworker-sdk-common bumped from ^1.2.0 to
^1.2.1
    * @launchdarkly/js-server-sdk-common bumped from ^2.7.0 to ^2.8.0
</details>

<details><summary>cloudflare-server-sdk: 2.5.15</summary>

##
[2.5.15](cloudflare-server-sdk-v2.5.14...cloudflare-server-sdk-v2.5.15)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/js-server-sdk-common-edge bumped from 2.4.0 to 2.4.1
</details>

<details><summary>js-client-sdk-common: 1.9.0</summary>

##
[1.9.0](js-client-sdk-common-v1.8.0...js-client-sdk-common-v1.9.0)
(2024-10-09)


### Features

* Add basic secure mode support for browser SDK.
([#598](#598))
([3389983](3389983))
* Add bootstrap support.
([#600](#600))
([4e5dbee](4e5dbee))
* Add ESM support for common and common-client (rollup)
([#604](#604))
([8cd0cdc](8cd0cdc))
* Add support for hooks.
([#605](#605))
([04d347b](04d347b))
* Add visibility handling to allow proactive event flushing.
([#607](#607))
([819a311](819a311))
* adds datasource status to sdk-client
([#590](#590))
([6f26204](6f26204))
* adds support for individual flag change listeners
([#608](#608))
([da31436](da31436))
* Browser-SDK Automatically start streaming based on event handlers.
([#592](#592))
([f2e5cbf](f2e5cbf))


### Bug Fixes

* Ensure client logger is always wrapped in a safe logger.
([#599](#599))
([980e4da](980e4da))
* Use flagVersion in analytics events.
([#611](#611))
([35fa033](35fa033))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.9.0 to 2.10.0
</details>

<details><summary>js-sdk-common: 2.10.0</summary>

##
[2.10.0](js-sdk-common-v2.9.0...js-sdk-common-v2.10.0)
(2024-10-09)


### Features

* Add ESM support for common and common-client (rollup)
([#604](#604))
([8cd0cdc](8cd0cdc))
* Add visibility handling to allow proactive event flushing.
([#607](#607))
([819a311](819a311))
* adds datasource status to sdk-client
([#590](#590))
([6f26204](6f26204))
</details>

<details><summary>js-server-sdk-common: 2.8.0</summary>

##
[2.8.0](js-server-sdk-common-v2.7.0...js-server-sdk-common-v2.8.0)
(2024-10-09)


### Features

* adds datasource status to sdk-client
([#590](#590))
([6f26204](6f26204))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-sdk-common bumped from 2.9.0 to 2.10.0
</details>

<details><summary>js-server-sdk-common-edge: 2.4.1</summary>

##
[2.4.1](js-server-sdk-common-edge-v2.4.0...js-server-sdk-common-edge-v2.4.1)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.7.0 to 2.8.0
</details>

<details><summary>node-server-sdk: 9.6.1</summary>

##
[9.6.1](node-server-sdk-v9.6.0...node-server-sdk-v9.6.1)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common bumped from 2.7.0 to 2.8.0
</details>

<details><summary>node-server-sdk-dynamodb: 6.1.23</summary>

##
[6.1.23](node-server-sdk-dynamodb-v6.1.22...node-server-sdk-dynamodb-v6.1.23)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.6.0 to 9.6.1
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.6.1
</details>

<details><summary>node-server-sdk-otel: 1.0.15</summary>

##
[1.0.15](node-server-sdk-otel-v1.0.14...node-server-sdk-otel-v1.0.15)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.6.0 to 9.6.1
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.6.1
</details>

<details><summary>node-server-sdk-redis: 4.1.23</summary>

##
[4.1.23](node-server-sdk-redis-v4.1.22...node-server-sdk-redis-v4.1.23)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @launchdarkly/node-server-sdk bumped from 9.6.0 to 9.6.1
  * peerDependencies
    * @launchdarkly/node-server-sdk bumped from >=9.4.3 to >=9.6.1
</details>

<details><summary>react-native-client-sdk: 10.8.0</summary>

##
[10.8.0](react-native-client-sdk-v10.7.0...react-native-client-sdk-v10.8.0)
(2024-10-09)


### Features

* Add support for hooks.
([#605](#605))
([04d347b](04d347b))


### Bug Fixes

* Ensure client logger is always wrapped in a safe logger.
([#599](#599))
([980e4da](980e4da))
* Fix base64 encoding of unicode characters.
([#613](#613))
([35ec8d1](35ec8d1))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.8.0 to 1.9.0
</details>

<details><summary>vercel-server-sdk: 1.3.18</summary>

##
[1.3.18](vercel-server-sdk-v1.3.17...vercel-server-sdk-v1.3.18)
(2024-10-09)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-server-sdk-common-edge bumped from 2.4.0 to 2.4.1
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Oct 9, 2024
kinyoklion pushed a commit that referenced this pull request Oct 10, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>js-client-sdk: 0.0.1</summary>

## 0.0.1 (2024-10-10)


### Features

* Add basic secure mode support for browser SDK.
([#598](#598))
([3389983](3389983))
* Add bootstrap support.
([#600](#600))
([4e5dbee](4e5dbee))
* Add browser info.
([#576](#576))
([a2f4398](a2f4398))
* Add ESM support for common and common-client (rollup)
([#604](#604))
([8cd0cdc](8cd0cdc))
* Add support for browser contract tests.
([#582](#582))
([38f081e](38f081e))
* Add support for hooks.
([#605](#605))
([04d347b](04d347b))
* Add support for js-client-sdk style initialization.
([53f5bb8](53f5bb8))
* Add support for localStorage for the browser platform.
([#566](#566))
([4792391](4792391))
* Add URLs for custom events and URL filtering.
([#587](#587))
([7131e69](7131e69))
* Add visibility handling to allow proactive event flushing.
([#607](#607))
([819a311](819a311))
* adds datasource status to sdk-client
([#590](#590))
([6f26204](6f26204))
* Adds support for REPORT.
([#575](#575))
([916b724](916b724))
* Browser-SDK Automatically start streaming based on event handlers.
([#592](#592))
([f2e5cbf](f2e5cbf))
* Implement browser crypto and encoding.
([#574](#574))
([e763e5d](e763e5d))
* Implement goals for client-side SDKs.
([#585](#585))
([fd38a8f](fd38a8f))
* Implement support for browser requests.
([#578](#578))
([887548a](887548a))
* Refactor data source connection handling.
([53f5bb8](53f5bb8))
* Scaffold browser client.
([#579](#579))
([0848ab7](0848ab7))


### Bug Fixes

* Ensure browser contract tests run during top-level build.
([#589](#589))
([7dfb14d](7dfb14d))
* Ensure client logger is always wrapped in a safe logger.
([#599](#599))
([980e4da](980e4da))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants