-
Notifications
You must be signed in to change notification settings - Fork 3
feat: foundation of an event processor #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
b45bbb2
Add event definitions
cwaldren-ld 75d23e6
Add IEventProcessor
cwaldren-ld 048552d
add test
cwaldren-ld 0ae641d
Refactor directory structure
cwaldren-ld 3a084c4
fix test
cwaldren-ld aa89779
many ideas, many failures, maybe a successful design
cwaldren-ld b2b249a
Merge branch 'main' into cw/sc-194812/event-processor
cwaldren-ld 6deaebe
Merge branch 'main' into cw/sc-194812/event-processor
cwaldren-ld d812d24
tests
cwaldren-ld f1e1c9b
add the config builders for events
cwaldren-ld a33c457
Rename ServiceEndpoints to ServiceHosts
cwaldren-ld e8b0c34
refactoring flush method
cwaldren-ld 83983cd
beginnings of event JSON serialization
cwaldren-ld 5f449e1
add tag_invoke for EvaluationReason
cwaldren-ld ca0bbaa
add contextKeys
cwaldren-ld 61a095d
add debug event serialization
cwaldren-ld 6ad708a
Add IdentifyEvent serialization
cwaldren-ld c6765d0
Add a helper type for dates
cwaldren-ld 8ee293f
Add variant dispatch for all OutputEvent types
cwaldren-ld 35e324b
Add private attributes builders to event processor config
cwaldren-ld ecc7e2f
Fix serialization of identify event
cwaldren-ld b6cd25f
refactor event classes into common and client namespaces
cwaldren-ld d1b1f43
Get rid of AsioEventProcessor wrapper
cwaldren-ld 41425af
add identify event sanity check
cwaldren-ld 69c1ece
fix a failure to rename
cwaldren-ld 431c519
more docs
cwaldren-ld 731d7a5
renamings for the style guide
cwaldren-ld 15629a3
Fix some doc comments that were accidentally changed in a renaming
cwaldren-ld d7d3f77
Revert "Rename ServiceEndpoints to ServiceHosts"
cwaldren-ld d48ca6d
remove TLS setter for event config
cwaldren-ld e23988f
Establish upper bound on number of input events using mutex
cwaldren-ld aff2575
fix a couple lints
cwaldren-ld 057881f
Make Debug/Feature events inherit from base class
cwaldren-ld f62c250
Merge branch 'main' into cw/sc-194283/event-processor
cwaldren-ld 762ead5
fix compilation due to unknown header in backoff.hpp
cwaldren-ld 994c276
Delete constructors of IEventProcessor
cwaldren-ld d58a6cb
add missing <functional> header to backoff.hpp
cwaldren-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
|
||
#include <chrono> | ||
#include <cstddef> | ||
#include <string> | ||
#include <unordered_map> | ||
#include "attribute_reference.hpp" | ||
namespace launchdarkly::config::detail { | ||
|
||
struct Events { | ||
public: | ||
template <typename SDK> | ||
friend class EventsBuilder; | ||
/** | ||
* Constructs configuration for the event subsystem. | ||
* @param capacity How many events can queue in memory before new events | ||
* are dropped. | ||
* @param flush_interval How often events are automatically flushed to | ||
* LaunchDarkly. | ||
* @param path The path component of the LaunchDarkly event delivery | ||
* endpoint. | ||
* @param all_attributes_private Whether all attributes should be treated as | ||
* private or not. | ||
* @param private_attrs Which attributes should be treated as private, if | ||
* all_attributes_private is false. | ||
* @param security Whether a plaintext or encrypted client should be used | ||
* for event delivery. | ||
*/ | ||
Events(std::size_t capacity, | ||
std::chrono::milliseconds flush_interval, | ||
std::string path, | ||
bool all_attributes_private, | ||
AttributeReference::SetType private_attrs); | ||
|
||
/** | ||
* Capacity of the event processor. | ||
*/ | ||
[[nodiscard]] std::size_t capacity() const; | ||
|
||
/** | ||
* Flush interval of the event processor, in milliseconds. | ||
*/ | ||
[[nodiscard]] std::chrono::milliseconds flush_interval() const; | ||
|
||
/** | ||
* Path component of the LaunchDarkly event delivery endpoint. | ||
*/ | ||
[[nodiscard]] std::string const& path() const; | ||
|
||
/** | ||
* Whether all attributes should be considered private or not. | ||
*/ | ||
[[nodiscard]] bool all_attributes_private() const; | ||
|
||
/** | ||
* Set of individual attributes that should be considered private. | ||
*/ | ||
[[nodiscard]] AttributeReference::SetType const& private_attributes() const; | ||
|
||
private: | ||
std::size_t capacity_; | ||
std::chrono::milliseconds flush_interval_; | ||
std::string path_; | ||
bool all_attributes_private_; | ||
AttributeReference::SetType private_attributes_; | ||
}; | ||
|
||
bool operator==(Events const& lhs, Events const& rhs); | ||
|
||
} // namespace launchdarkly::config::detail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#pragma once | ||
|
||
#include <tl/expected.hpp> | ||
#include "attribute_reference.hpp" | ||
#include "config/detail/events.hpp" | ||
#include "error.hpp" | ||
|
||
#include <memory> | ||
#include <optional> | ||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace launchdarkly::config::detail { | ||
|
||
template <typename SDK> | ||
class EventsBuilder; | ||
|
||
template <typename SDK> | ||
bool operator==(EventsBuilder<SDK> const& lhs, EventsBuilder<SDK> const& rhs); | ||
|
||
/** | ||
* EventsBuilder allows for specification of parameters related to the | ||
* SDK's event processor. | ||
* | ||
* @tparam SDK Type of SDK, such as ClientSDK or ServerSDK. | ||
*/ | ||
template <typename SDK> | ||
class EventsBuilder { | ||
public: | ||
friend bool operator== | ||
<SDK>(EventsBuilder<SDK> const& lhs, EventsBuilder<SDK> const& rhs); | ||
/** | ||
* Constructs an EventsBuilder. | ||
*/ | ||
EventsBuilder(); | ||
|
||
/** | ||
* Sets the capacity of the event processor. When more events are generated | ||
* within the processor's flush interval than this value, events will be | ||
* dropped. | ||
* @param capacity Event queue capacity. | ||
* @return Reference to this builder. | ||
*/ | ||
EventsBuilder& capacity(std::size_t capacity); | ||
|
||
/** | ||
* Sets the flush interval of the event processor. The processor queues | ||
* outgoing events based on the capacity parameter; these events are then | ||
* delivered based on the flush interval. | ||
* @param interval Interval between automatic flushes. | ||
* @return Reference to this builder. | ||
*/ | ||
EventsBuilder& flush_interval(std::chrono::milliseconds interval); | ||
|
||
/** | ||
* Attribute privacy indicates whether or not attributes should be | ||
* retained by LaunchDarkly after being sent upon initialization, | ||
* and if attributes should later be sent in events. | ||
* | ||
* Attribute privacy may be specified in 3 ways: | ||
* | ||
* (1) To specify that all attributes should be considered private - not | ||
* just those designated private on a per-context basis - call this method | ||
* with true as the parameter. | ||
* | ||
* (2) To specify that a specific set of attributes should be considered | ||
* private - in addition to those designated private on a per-context basis | ||
* - call @ref private_attributes. | ||
* | ||
* (3) To specify private attributes on a per-context basis, it is not | ||
* necessary to call either of these methods, as the default behavior is to | ||
* treat all attributes as non-private unless otherwise specified. | ||
* | ||
* @param value True for behavior of (1), false for default behavior of (2) | ||
* or (3). | ||
* @return Reference to this builder. | ||
*/ | ||
EventsBuilder& all_attributes_private(bool); | ||
|
||
/** | ||
* Specify that a set of attributes are private. | ||
* @return Reference to this builder. | ||
*/ | ||
EventsBuilder& private_attributes( | ||
AttributeReference::SetType private_attrs); | ||
|
||
/** | ||
* Builds Events configuration, if the configuration is valid. | ||
* @return Events config, or error. | ||
*/ | ||
[[nodiscard]] tl::expected<Events, Error> build(); | ||
|
||
private: | ||
Events config_; | ||
}; | ||
|
||
} // namespace launchdarkly::config::detail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include "events/common_events.hpp" | ||
|
||
namespace launchdarkly::events::client { | ||
|
||
struct IdentifyEventParams { | ||
Date creation_date; | ||
Context context; | ||
}; | ||
|
||
struct IdentifyEvent { | ||
Date creation_date; | ||
EventContext context; | ||
}; | ||
|
||
struct FeatureEventParams { | ||
Date creation_date; | ||
std::string key; | ||
Context context; | ||
EvaluationResult eval_result; | ||
}; | ||
|
||
struct FeatureEventBase { | ||
Date creation_date; | ||
std::string key; | ||
Version version; | ||
std::optional<VariationIndex> variation; | ||
Value value; | ||
std::optional<Reason> reason; | ||
Value default_; | ||
}; | ||
|
||
struct FeatureEvent : public FeatureEventBase { | ||
ContextKeys context_keys; | ||
}; | ||
|
||
struct DebugEvent : public FeatureEventBase { | ||
EventContext context; | ||
}; | ||
|
||
} // namespace launchdarkly::events::client |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.