|
1 | 1 | import DataSourceStatusErrorInfo from './DataSourceStatusErrorInfo'; |
2 | 2 |
|
3 | 3 | // 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; |
5 | 65 |
|
6 | 66 | export default interface DataSourceStatus { |
7 | 67 | /** |
|
0 commit comments