Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions launchdarkly-server-sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ impl Client {
Ok(true)
}

/// Forcefully sets the client to initialized without making any outbound calls.
///
/// This acts as a pseudo-offline mode, where the `DataStore` is still read from. This should only be used in
/// cases where the `DataStore` is managed outside of launchdarkly-server-sdk.
pub fn force_initialized(&self) {
self.started.store(true, Ordering::SeqCst);
self.init_state
.store(ClientInitState::Initialized as usize, Ordering::SeqCst);
}

/// This is an async method that will resolve once initialization is complete.
/// Initialization being complete does not mean that initialization was a success.
/// The return value from the method indicates if the client successfully initialized.
Expand Down
3 changes: 3 additions & 0 deletions launchdarkly-server-sdk/src/data_source_builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ impl<C> Default for StreamingDataSourceBuilder<C> {
}
}

/// An implementation of DataSourceFactory that will not make any outbound calls. This should
/// only be used when filling a DataStore externally.
#[derive(Clone)]
pub struct NullDataSourceBuilder {}

impl NullDataSourceBuilder {
/// Create a new [NullDataSourceBuilder] with all default values.
pub fn new() -> Self {
Self {}
}
Expand Down
3 changes: 2 additions & 1 deletion launchdarkly-server-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub use client::Client;
pub use client::{BuildError, StartError};
pub use config::{ApplicationInfo, BuildError as ConfigBuildError, Config, ConfigBuilder};
pub use data_source_builders::{
BuildError as DataSourceBuildError, PollingDataSourceBuilder, StreamingDataSourceBuilder,
BuildError as DataSourceBuildError, NullDataSourceBuilder, PollingDataSourceBuilder,
StreamingDataSourceBuilder,
};
pub use evaluation::{FlagDetail, FlagDetailConfig};
pub use events::event::MigrationOpEvent;
Expand Down