Expand description
Types for implementing custom FDv2 data sources.
This module is experimental and not subject to semantic versioning. Its API may change in any release.
§Examples
Implement a custom synchronizer and add it to a data system.
use launchdarkly_server_sdk::data_sources::{
DataSourceBuildContext, FDv2SourceEvent, FDv2SourceEventFuture, FDv2SourceResult,
FDv2SynchronizerConfig, Selector, Synchronizer, SynchronizerFactory,
};
use launchdarkly_server_sdk::{ConfigBuilder, DataSystemBuildError, DataSystemBuilder};
struct MySynchronizer;
impl Synchronizer for MySynchronizer {
fn next(&mut self, _selector: Selector) -> FDv2SourceEventFuture<'_> {
Box::pin(async {
FDv2SourceEvent {
result: FDv2SourceResult::Goodbye,
fdv1_fallback: None,
}
})
}
fn name(&self) -> &str {
"my-synchronizer"
}
}
struct MyFactory;
impl SynchronizerFactory for MyFactory {
fn create(&self) -> Box<dyn Synchronizer> {
Box::new(MySynchronizer)
}
}
#[derive(Clone)]
struct MyConfig;
impl FDv2SynchronizerConfig for MyConfig {
fn build_synchronizer(
&self,
_context: &DataSourceBuildContext,
) -> Result<Box<dyn SynchronizerFactory>, DataSystemBuildError> {
Ok(Box::new(MyFactory))
}
fn to_owned(&self) -> Box<dyn FDv2SynchronizerConfig> {
Box::new(self.clone())
}
}
let mut data_system = DataSystemBuilder::custom();
data_system.synchronizer(MyConfig);
ConfigBuilder::new("sdk-key").data_system(&data_system);Structs§
- Change
Set - A batch of flag and segment changes delivered by a data source.
- Data
Source Build Context - The inputs a data source needs to build itself.
- Error
Info - Describes an error surfaced by a data source.
- FDv1
Fallback Directive - An instruction from LaunchDarkly to fall back to the FDv1 protocol.
- FDv2
Source Event - A source result paired with any FDv1 fallback directive seen on the same response.
- Request
Headers - The HTTP headers attached to every FDv2 request.
Enums§
- Change
SetKind - Whether a change set is a full payload, an incremental update, or carries no changes.
- Error
Kind - Classifies why a data source is interrupted or has failed.
- FDv2
Source Result - The outcome of a single data source poll or stream read.
- Item
Change - A single flag or segment change within a change set.
Traits§
- FDv2
Initializer Config - A configured FDv2 source usable as an initializer.
- FDv2
Synchronizer Config - A configured FDv2 source usable as a synchronizer.
- Initializer
- A data source that can obtain an initial payload.
- Initializer
Factory - Produces a fresh initializer each time the orchestrator starts a run.
- Synchronizer
- A data source that keeps flag data up to date.
- Synchronizer
Factory - Produces a fresh synchronizer each time the orchestrator starts a run.
Type Aliases§
- FDv2
Source Event Future - The future returned by an initializer or synchronizer as it produces an event.
- Selector
- Identifies a point in the flag-data stream, echoed back to request the next changes.