-
Notifications
You must be signed in to change notification settings - Fork 31
feat: adds datasource status to sdk-client #590
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
Changes from 15 commits
60aae7c
7ef3b5c
6ef2c49
2849c1f
6f8c6b5
ff6dda5
c4879f5
d95111f
1c584d3
6028c89
90bbc69
a2787a6
ae3f473
1c24e1b
8dd7590
47b6b70
ddeb130
60ce6c5
7df3547
15adf36
11e430c
df41f81
57796af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
|
|
||
| /// An I/O error such as a dropped connection. | ||
| NetworkError, | ||
|
|
||
| /// The LaunchDarkly service returned an HTTP response with an error | ||
| /// status, available in the status code. | ||
| ErrorResponse, | ||
|
|
||
| /// The SDK received malformed data from the LaunchDarkly service. | ||
| InvalidData, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* eslint-disable max-classes-per-file */ | ||
| import { DataSourceErrorKind } from './DataSourceErrorKinds'; | ||
|
|
||
| export class LDFileDataSourceError extends Error { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| 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; | ||
| } | ||
| } | ||
|
|
||
| export type StreamingErrorHandler = (err: LDStreamingError) => void; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { DataSourceErrorKind } from './DataSourceErrorKinds'; | ||
| import { | ||
| LDFileDataSourceError, | ||
| LDPollingError, | ||
| LDStreamingError, | ||
| StreamingErrorHandler, | ||
| } from './errors'; | ||
|
|
||
| export { | ||
| DataSourceErrorKind, | ||
| LDFileDataSourceError, | ||
| LDPollingError, | ||
| LDStreamingError, | ||
| StreamingErrorHandler, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| export * from './context'; | ||
| export * from './datasource'; | ||
| export * from './diagnostics'; | ||
| export * from './evaluation'; | ||
| export * from './events'; | ||
| export * from './stream'; | ||
| export * from './context'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import StreamingProcessor from './StreamingProcessor'; | ||
| import type { StreamingErrorHandler } from './types'; | ||
|
|
||
| export { StreamingProcessor }; | ||
| export type { StreamingErrorHandler }; |
This file was deleted.
There was a problem hiding this comment.
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