Skip to content

Commit 431c519

Browse files
committed
more docs
1 parent 69c1ece commit 431c519

File tree

6 files changed

+76
-24
lines changed

6 files changed

+76
-24
lines changed

libs/common/include/config/detail/config_builder.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace launchdarkly::config::detail {
1818
template <typename SDK>
1919
class ConfigBuilder {
2020
public:
21-
using EndpointsBuilder = detail::HostsBuilder<SDK>;
21+
using HostsBuilder = detail::HostsBuilder<SDK>;
2222
using EventsBuilder = detail::EventsBuilder<SDK>;
2323
using ConfigType = detail::Config<SDK>;
2424
/**
@@ -28,12 +28,12 @@ class ConfigBuilder {
2828
ConfigBuilder(std::string sdk_key);
2929

3030
/**
31-
* To customize the endpoints the SDK uses for streaming, polling, and
32-
* events, pass in an EndpointsBuilder.
33-
* @param builder An EndpointsBuilder.
31+
* To customize the hosts the SDK uses for streaming, polling, and
32+
* events, pass in an HostsBuilder.
33+
* @param builder A HostsBuilder.
3434
* @return Reference to this builder.
3535
*/
36-
ConfigBuilder& service_endpoints(EndpointsBuilder builder);
36+
ConfigBuilder& service_hosts(HostsBuilder builder);
3737

3838
/**
3939
* To include metadata about the application that is utilizing the SDK,
@@ -68,7 +68,7 @@ class ConfigBuilder {
6868
private:
6969
std::string sdk_key_;
7070
std::optional<bool> offline_;
71-
std::optional<EndpointsBuilder> service_endpoints_builder_;
71+
std::optional<HostsBuilder> service_hosts_builder_;
7272
std::optional<ApplicationInfo> application_info_builder_;
7373
std::optional<EventsBuilder> events_builder_;
7474
};

libs/common/include/config/detail/events.hpp

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,73 @@
77
#include "attribute_reference.hpp"
88
namespace launchdarkly::config::detail {
99

10+
/**
11+
* Specifies the security regime for event delivery.
12+
*/
1013
enum class TransportSecurity {
14+
// Plaintext event delivery.
1115
None = 0,
16+
// Event delivery secured by Transport Layer Security.
1217
TLS = 1,
1318
};
1419

1520
struct Events {
1621
public:
1722
template <typename SDK>
1823
friend class EventsBuilder;
24+
/**
25+
* Constructs configuration for the event subsystem.
26+
* @param capacity How many events can queue in memory before new events
27+
* are dropped.
28+
* @param flush_interval How often events are automatically flushed to LaunchDarkly.
29+
* @param path The path component of the LaunchDarkly event delivery endpoint.
30+
* @param all_attributes_private Whether all attributes should be treated as private or not.
31+
* @param private_attrs Which attributes should be treated as private, if all_attributes_private is false.
32+
* @param security Whether a plaintext or encrypted client should be used for event delivery.
33+
*/
1934
Events(std::size_t capacity,
2035
std::chrono::milliseconds flush_interval,
2136
std::string path,
2237
bool all_attributes_private,
2338
AttributeReference::SetType private_attrs,
2439
TransportSecurity security);
25-
std::size_t capacity() const;
26-
std::chrono::milliseconds flush_interval() const;
27-
std::string const& path() const;
28-
bool all_attributes_private() const;
29-
AttributeReference::SetType const& private_attributes() const;
30-
TransportSecurity transport_security() const;
40+
41+
/**
42+
* Capacity of the event processor.
43+
*/
44+
[[nodiscard]] std::size_t capacity() const;
45+
46+
/**
47+
* Flush interval of the event processor, in milliseconds.
48+
*/
49+
[[nodiscard]] std::chrono::milliseconds flush_interval() const;
50+
51+
/**
52+
* Path component of the LaunchDarkly event delivery endpoint.
53+
*/
54+
[[nodiscard]] std::string const& path() const;
55+
56+
/**
57+
* Whether all attributes should be considered private or not.
58+
*/
59+
[[nodiscard]] bool all_attributes_private() const;
60+
61+
/**
62+
* Set of individual attributes that should be considered private.
63+
*/
64+
[[nodiscard]] AttributeReference::SetType const& private_attributes() const;
65+
66+
/**
67+
* Requested transport security.
68+
*/
69+
[[nodiscard]] TransportSecurity transport_security() const;
3170

3271
private:
3372
std::size_t capacity_;
3473
std::chrono::milliseconds flush_interval_;
3574
std::string path_;
3675
bool all_attributes_private_;
3776
AttributeReference::SetType private_attributes_;
38-
3977
TransportSecurity transport_security_;
4078
};
4179

libs/common/include/config/detail/events_builder.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class EventsBuilder {
3838
* Sets the capacity of the event processor. When more events are generated
3939
* within the processor's flush interval than this value, events will be
4040
* dropped.
41-
* @param capacity Event capacity.
41+
* @param capacity Event queue capacity.
4242
* @return Reference to this builder.
4343
*/
4444
EventsBuilder& capacity(std::size_t capacity);
@@ -79,15 +79,22 @@ class EventsBuilder {
7979
EventsBuilder& all_attributes_private(bool);
8080

8181
/**
82-
* Specify an AttributePolicy for individual attributes.
83-
* @return
82+
* Specify that a set of attributes are private.
83+
* @return Reference to this builder.
8484
*/
8585
EventsBuilder& private_attributes(
8686
AttributeReference::SetType private_attrs);
8787

8888
/**
89-
* Builds Events configuration, if the configuration is valid. If not,
90-
* returns an error.
89+
* Specify the transport security regime for event delivery. By default,
90+
* events are delivered using TLS.
91+
* @param regime Security regime.
92+
* @return Reference to this builder.
93+
*/
94+
EventsBuilder& transport_security(TransportSecurity regime);
95+
96+
/**
97+
* Builds Events configuration, if the configuration is valid.
9198
* @return Events config, or error.
9299
*/
93100
[[nodiscard]] tl::expected<Events, Error> build();

libs/common/src/config/config_builder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ template <typename SDK>
66
ConfigBuilder<SDK>::ConfigBuilder(std::string sdk_key)
77
: sdk_key_(std::move(sdk_key)),
88
offline_(std::nullopt),
9-
service_endpoints_builder_(std::nullopt) {}
9+
service_hosts_builder_(std::nullopt) {}
1010

1111
template <typename SDK>
12-
ConfigBuilder<SDK>& ConfigBuilder<SDK>::service_endpoints(
12+
ConfigBuilder<SDK>& ConfigBuilder<SDK>::service_hosts(
1313
detail::HostsBuilder<SDK> builder) {
14-
service_endpoints_builder_ = std::move(builder);
14+
service_hosts_builder_ = std::move(builder);
1515
return *this;
1616
}
1717

@@ -40,7 +40,7 @@ typename ConfigBuilder<SDK>::ConfigType ConfigBuilder<SDK>::build(
4040
Logger& logger) const {
4141
auto key = sdk_key_;
4242
auto offline = offline_.value_or(Defaults<detail::AnySDK>::offline());
43-
auto endpoints = service_endpoints_builder_.value_or(EndpointsBuilder());
43+
auto endpoints = service_hosts_builder_.value_or(HostsBuilder());
4444
auto events = events_builder_.value_or(EventsBuilder());
4545
std::optional<std::string> app_tag;
4646
if (application_info_builder_) {

libs/common/src/config/events_builder.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ EventsBuilder<SDK>& EventsBuilder<SDK>::private_attributes(
3333
return *this;
3434
}
3535

36+
template <typename SDK>
37+
EventsBuilder<SDK>& EventsBuilder<SDK>::transport_security(
38+
TransportSecurity regime) {
39+
config_.transport_security_ = regime;
40+
return *this;
41+
}
42+
3643
template <typename SDK>
3744
tl::expected<Events, Error> EventsBuilder<SDK>::build() {
3845
if (config_.capacity() == 0) {

libs/common/tests/config_builder_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TEST_F(ConfigBuilderTest,
3131
using namespace launchdarkly::client;
3232
ConfigBuilder builder("sdk-123");
3333
Config cfg = builder.build(logger);
34-
ASSERT_EQ(cfg.hosts_builder, ConfigBuilder::EndpointsBuilder());
34+
ASSERT_EQ(cfg.hosts_builder, ConfigBuilder::HostsBuilder());
3535
}
3636

3737
TEST_F(ConfigBuilderTest,
@@ -48,7 +48,7 @@ TEST_F(ConfigBuilderTest, CustomBuilderReflectsChanges) {
4848
auto config =
4949
ConfigBuilder("sdk-123")
5050
.offline(true)
51-
.service_endpoints(HostsBuilder().relay_proxy("foo"))
51+
.service_hosts(HostsBuilder().relay_proxy("foo"))
5252
.application_info(
5353
ApplicationInfo().app_identifier("bar").app_version("baz"))
5454
.build(logger);

0 commit comments

Comments
 (0)