Skip to content

Commit faf67e0

Browse files
committed
docs: adding documentation for the different values for data source state
1 parent 1e0ea26 commit faf67e0

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

packages/shared/sdk-client/src/datasource/DataSourceStatus.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,67 @@
11
import DataSourceStatusErrorInfo from './DataSourceStatusErrorInfo';
22

33
// TODO: SDK-702 - Implement network availability behaviors - add 'NETWORK_UNAVAILABLE' when implemented
4-
export type DataSourceState = 'INITIALIZING' | 'VALID' | 'INTERRUPTED' | 'SET_OFFLINE' | 'CLOSED';
4+
5+
/**
6+
* The initial state of the data source when the SDK is being
7+
* initialized.
8+
*
9+
* If it encounters an error that requires it to retry initialization,
10+
* the state will remain at Initializing until it either succeeds and
11+
* becomes {@link DataSourceValidState}, or permanently fails and becomes
12+
* {@link DataSourceClosedState}.
13+
*/
14+
export type DataSourceInitializingState = 'INITIALIZING';
15+
16+
/**
17+
* Indicates that the data source is currently operational and has not
18+
* had any problems since the last time it recieved data.
19+
*
20+
* In streaming mode, this means that there is currently an open stream
21+
* connection and that at least one initial message has been recieved on
22+
* the stream. In polling mode, this means that the last poll request
23+
* succeeded.
24+
*/
25+
export type DataSourceValidState = 'VALID';
26+
27+
/**
28+
* Indicates that the data source encountered an error that it will
29+
* attempt to recover from.
30+
*
31+
* In streaming mode, this means that the stream connection failed, or
32+
* had to be dropped due to some other error, and will be retried after
33+
* a backoff delay. In polling mode, it means that the last poll request
34+
* failed, and a new poll request will be made after the configured
35+
* polling interval.
36+
*
37+
* @remarks
38+
* Currently, support for this state is unreliable in the client-side SDKs
39+
* due to limitations with default EventSource implementations. We do not
40+
* recommend solely relying on this state for your application logic.
41+
*/
42+
export type DataSourceInterruptedState = 'INTERRUPTED';
43+
44+
/**
45+
* Indicates that the application has told the SDK to stay offline.
46+
*/
47+
export type DataSourceSetOfflineState = 'SET_OFFLINE';
48+
49+
/**
50+
* Indicates that the data source has been permanently closed.
51+
*
52+
* This could be because it encountered an unrecoverable error (for
53+
* instance, the LaunchDarkly service rejected the client key; an invalid
54+
* client key will never become valid), or because the SDK client was
55+
* explicitly shut down.
56+
*/
57+
export type DataSourceClosedState = 'CLOSED';
58+
59+
export type DataSourceState =
60+
| DataSourceInitializingState
61+
| DataSourceValidState
62+
| DataSourceInterruptedState
63+
| DataSourceSetOfflineState
64+
| DataSourceClosedState;
565

666
export default interface DataSourceStatus {
767
/**

packages/shared/sdk-client/src/datasource/DataSourceStatusManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DataSourceErrorKind } from '@launchdarkly/js-sdk-common';
22

33
import LDEmitter from '../LDEmitter';
4-
import DataSourceStatus, { DataSourceState } from './DataSourceStatus';
4+
import DataSourceStatus, { type DataSourceState } from './DataSourceStatus';
55
import DataSourceStatusErrorInfo from './DataSourceStatusErrorInfo';
66

77
/**

0 commit comments

Comments
 (0)