-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathifdv2_synchronizer.hpp
More file actions
63 lines (53 loc) · 2.05 KB
/
Copy pathifdv2_synchronizer.hpp
File metadata and controls
63 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "fdv2_source_result.hpp"
#include <launchdarkly/async/promise.hpp>
#include <launchdarkly/data_model/selector.hpp>
#include <string>
namespace launchdarkly::client_side::data_sources {
/**
* A continuous data source that produces a stream of results, used to keep
* flag data current once initialization is complete.
*
* The underlying connection is started lazily on the first call to Next() and
* runs until Close() is called.
*
* Implementations must be thread-safe to the extent this contract needs:
* Next() is called from one thread at a time, and Close() may be called
* concurrently with it from another.
*/
class IFDv2Synchronizer {
public:
/**
* Returns a Future that resolves with the next result once it is
* available.
*
* On the first call, the synchronizer starts its underlying connection.
* Subsequent calls continue reading from the same connection.
*
* Close() may be called from another thread to unblock Next(), in which
* case the future resolves with FDv2SourceResult::Shutdown.
*
* @param selector The selector to send with the request, reflecting any
* changesets applied since the previous call. An empty selector asks for
* a full data set.
*/
virtual async::Future<FDv2SourceResult> Next(
data_model::Selector selector) = 0;
/**
* Unblocks any in-progress Next() call, causing it to return
* FDv2SourceResult::Shutdown, and releases underlying resources.
*/
virtual void Close() = 0;
/**
* @return A display-suitable name of the synchronizer.
*/
[[nodiscard]] virtual std::string const& Identity() const = 0;
virtual ~IFDv2Synchronizer() = default;
IFDv2Synchronizer(IFDv2Synchronizer const&) = delete;
IFDv2Synchronizer(IFDv2Synchronizer&&) = delete;
IFDv2Synchronizer& operator=(IFDv2Synchronizer const&) = delete;
IFDv2Synchronizer& operator=(IFDv2Synchronizer&&) = delete;
protected:
IFDv2Synchronizer() = default;
};
} // namespace launchdarkly::client_side::data_sources