-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds datasource status to sdk-client (#590)
**Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] 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. --------- Co-authored-by: Ryan Lamb <[email protected]>
- Loading branch information
1 parent
980e4da
commit 6f26204
Showing
27 changed files
with
691 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/shared/common/src/datasource/DataSourceErrorKinds.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export enum DataSourceErrorKind { | ||
/// An unexpected error, such as an uncaught exception, further | ||
/// described by the error message. | ||
Unknown = 'UNKNOWN', | ||
|
||
/// An I/O error such as a dropped connection. | ||
NetworkError = 'NETWORK_ERROR', | ||
|
||
/// The LaunchDarkly service returned an HTTP response with an error | ||
/// status, available in the status code. | ||
ErrorResponse = 'ERROR_RESPONSE', | ||
|
||
/// The SDK received malformed data from the LaunchDarkly service. | ||
InvalidData = 'INVALID_DATA', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
import { DataSourceErrorKind } from './DataSourceErrorKinds'; | ||
|
||
export class LDFileDataSourceError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
this.name = 'LaunchDarklyFileDataSourceError'; | ||
} | ||
} | ||
|
||
export class LDPollingError extends Error { | ||
public readonly kind: DataSourceErrorKind; | ||
public readonly status?: number; | ||
public readonly recoverable: boolean; | ||
|
||
constructor(kind: DataSourceErrorKind, message: string, status?: number, recoverable = true) { | ||
super(message); | ||
this.kind = kind; | ||
this.status = status; | ||
this.name = 'LaunchDarklyPollingError'; | ||
this.recoverable = recoverable; | ||
} | ||
} | ||
|
||
export class LDStreamingError extends Error { | ||
public readonly kind: DataSourceErrorKind; | ||
public readonly code?: number; | ||
public readonly recoverable: boolean; | ||
|
||
constructor(kind: DataSourceErrorKind, message: string, code?: number, recoverable = true) { | ||
super(message); | ||
this.kind = kind; | ||
this.code = code; | ||
this.name = 'LaunchDarklyStreamingError'; | ||
this.recoverable = recoverable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { DataSourceErrorKind } from './DataSourceErrorKinds'; | ||
import { LDFileDataSourceError, LDPollingError, LDStreamingError } from './errors'; | ||
|
||
export { DataSourceErrorKind, LDFileDataSourceError, LDPollingError, LDStreamingError }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './context'; | ||
export * from './diagnostics'; | ||
export * from './evaluation'; | ||
export * from './events'; | ||
export * from './stream'; | ||
export * from './context'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { LDStreamingError } from '../../errors'; | ||
import { LDStreamingError } from '../../datasource/errors'; | ||
|
||
export type StreamingErrorHandler = (err: LDStreamingError) => void; |
Oops, something went wrong.