|
C++ Server-Side SDK
LaunchDarkly SDK
|
#include <source_manager.hpp>
Public Member Functions | |
| SourceManager (std::vector< std::unique_ptr< data_interfaces::IFDv2SynchronizerFactory >> factories) | |
| std::unique_ptr< data_interfaces::IFDv2Synchronizer > | NextSynchronizer () |
| void | BlockCurrentSynchronizer () |
| void | ResetSourceIndex () |
| void | SwitchToFDv1Fallback () |
| void | SwitchBackToFDv2 () |
| bool | IsPrimeSynchronizer () const |
| std::size_t | AvailableSynchronizerCount () const |
| std::size_t | SynchronizerCount () const |
| bool | IsCurrentSynchronizerFDv1Fallback () const |
| SourceManager (SourceManager const &)=delete | |
| SourceManager (SourceManager &&)=delete | |
| SourceManager & | operator= (SourceManager const &)=delete |
| SourceManager & | operator= (SourceManager &&)=delete |
Manages a list of synchronizer factories together with per-factory state (Available / Blocked) and the index of the currently active factory.
Iteration is cyclic: NextSynchronizer advances past the end and wraps to the beginning, skipping any factory in the Blocked state. A factory enters the Blocked state when BlockCurrentSynchronizer is called (typically on a terminal error). Once blocked, a factory is not eligible to be built again until unblocked.
ResetSourceIndex causes the next call to start iteration at index 0 — used by recovery, which wants to fall back to the most-preferred Available synchronizer.
Factories whose IsFDv1Fallback() returns true start in the Blocked state.
Not thread-safe. The caller is responsible for serializing all calls.
| std::size_t launchdarkly::server_side::data_systems::SourceManager::AvailableSynchronizerCount | ( | ) | const |
Returns the count of factories not in the Blocked state.
| void launchdarkly::server_side::data_systems::SourceManager::BlockCurrentSynchronizer | ( | ) |
Marks the currently tracked factory as Blocked. No-op if no factory is currently tracked.
| bool launchdarkly::server_side::data_systems::SourceManager::IsCurrentSynchronizerFDv1Fallback | ( | ) | const |
Returns true if the currently tracked factory is the FDv1 fallback synchronizer.
| bool launchdarkly::server_side::data_systems::SourceManager::IsPrimeSynchronizer | ( | ) | const |
Returns true if the currently tracked factory is the first Available factory in the list. Returns false if no factory is currently tracked.
| std::unique_ptr< IFDv2Synchronizer > launchdarkly::server_side::data_systems::SourceManager::NextSynchronizer | ( | ) |
Advances to the next Available synchronizer factory (wrapping past the end), builds a synchronizer instance from it, and records that factory as the current one for subsequent queries. Returns nullptr if no Available factory exists.
| void launchdarkly::server_side::data_systems::SourceManager::ResetSourceIndex | ( | ) |
Resets the iteration cursor so that the next call to NextSynchronizer begins searching from index 0.
| void launchdarkly::server_side::data_systems::SourceManager::SwitchBackToFDv2 | ( | ) |
Returns synchronizer state to the initial configuration, including unblocking factories previously blocked by terminal errors.
| void launchdarkly::server_side::data_systems::SourceManager::SwitchToFDv1Fallback | ( | ) |
Blocks every non-FDv1 factory and unblocks the FDv1 fallback factory, if one was configured. Resets the iteration cursor so the next call to NextSynchronizer returns the FDv1 fallback. If no FDv1 fallback factory was configured, every factory is left blocked.
| std::size_t launchdarkly::server_side::data_systems::SourceManager::SynchronizerCount | ( | ) | const |
Returns the total number of factories configured at construction (including any currently in the Blocked state). Constant for the lifetime of the SourceManager.