Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This includes shared libraries, used by SDKs and other tools, as well as SDKs.
## Organization

| Directory | Description |
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| .github | Contains CI and release process workflows and actions. |
| examples | Contains examples (hello-world style). |
| contract-tests | Contains contract test service. |
Expand Down
2 changes: 1 addition & 1 deletion contract-tests/client-contract-tests/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "server.hpp"

Check failure on line 1 in contract-tests/client-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/client-contract-tests/src/main.cpp:1:10 [clang-diagnostic-error]

'server.hpp' file not found

#include <launchdarkly/logging/console_backend.hpp>

Expand All @@ -18,7 +18,7 @@
using launchdarkly::LogLevel;

int main(int argc, char* argv[]) {
launchdarkly::Logger logger{

Check warning on line 21 in contract-tests/client-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/client-contract-tests/src/main.cpp:21:26 [cppcoreguidelines-init-variables]

variable 'logger' is not initialized
std::make_unique<ConsoleBackend>("client-contract-tests")};

std::string const default_port = "8123";
Expand All @@ -31,8 +31,8 @@
try {
net::io_context ioc{1};

auto p = boost::lexical_cast<unsigned short>(port);

Check warning on line 34 in contract-tests/client-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/client-contract-tests/src/main.cpp:34:14 [readability-identifier-length]

variable name 'p' is too short, expected at least 3 characters
server srv(ioc, "0.0.0.0", p, logger);

Check warning on line 35 in contract-tests/client-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/client-contract-tests/src/main.cpp:35:16 [cppcoreguidelines-init-variables]

variable 'srv' is not initialized

srv.add_capability("client-side");
srv.add_capability("mobile");
Expand All @@ -41,7 +41,7 @@
srv.add_capability("service-endpoints");
srv.add_capability("tags");
srv.add_capability("client-independence");
srv.add_capability("inline-context");
srv.add_capability("inline-context-all");
srv.add_capability("anonymous-redaction");
srv.add_capability("tls:verify-peer");
srv.add_capability("tls:skip-verify-peer");
Expand Down
2 changes: 1 addition & 1 deletion contract-tests/server-contract-tests/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "server.hpp"

Check failure on line 1 in contract-tests/server-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/server-contract-tests/src/main.cpp:1:10 [clang-diagnostic-error]

'server.hpp' file not found

#include <launchdarkly/logging/console_backend.hpp>

Expand All @@ -18,7 +18,7 @@
using launchdarkly::LogLevel;

int main(int argc, char* argv[]) {
launchdarkly::Logger logger{

Check warning on line 21 in contract-tests/server-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/server-contract-tests/src/main.cpp:21:26 [cppcoreguidelines-init-variables]

variable 'logger' is not initialized
std::make_unique<ConsoleBackend>("server-contract-tests")};

std::string const default_port = "8123";
Expand All @@ -31,8 +31,8 @@
try {
net::io_context ioc{1};

auto const p = boost::lexical_cast<unsigned short>(port);

Check warning on line 34 in contract-tests/server-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/server-contract-tests/src/main.cpp:34:20 [readability-identifier-length]

variable name 'p' is too short, expected at least 3 characters
server srv{ioc, "0.0.0.0", p, logger};

Check warning on line 35 in contract-tests/server-contract-tests/src/main.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/contract-tests/server-contract-tests/src/main.cpp:35:16 [cppcoreguidelines-init-variables]

variable 'srv' is not initialized

srv.add_capability("server-side");
srv.add_capability("strongly-typed");
Expand All @@ -40,7 +40,7 @@
srv.add_capability("service-endpoints");
srv.add_capability("tags");
srv.add_capability("server-side-polling");
srv.add_capability("inline-context");
srv.add_capability("inline-context-all");
srv.add_capability("anonymous-redaction");
srv.add_capability("tls:verify-peer");
srv.add_capability("tls:skip-verify-peer");
Expand Down
4 changes: 1 addition & 3 deletions libs/client-sdk/src/client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
std::unordered_map<Client::FlagKey, Value> result;
for (auto& [key, descriptor] : flag_manager_.Store().GetAll()) {
if (descriptor->item) {
result.try_emplace(key, descriptor->item->Detail().Value());

Check warning on line 214 in libs/client-sdk/src/client_impl.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/client-sdk/src/client_impl.cpp:214:37 [bugprone-unchecked-optional-access]

unchecked access to optional value
}
}
return result;
Expand All @@ -221,9 +221,7 @@
std::optional<Value> data,
std::optional<double> metric_value) {
event_processor_->SendAsync(events::TrackEventParams{
std::chrono::system_clock::now(), std::move(event_name),
ReadContextSynchronized(
[](Context const& c) { return c.KindsToKeys(); }),
std::chrono::system_clock::now(), std::move(event_name), context_,
std::move(data), metric_value});
}

Expand All @@ -246,7 +244,7 @@
}

template <typename T>
EvaluationDetail<T> ClientImpl::VariationInternal(FlagKey const& key,

Check warning on line 247 in libs/client-sdk/src/client_impl.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/client-sdk/src/client_impl.cpp:247:51 [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'VariationInternal' of convertible types are easily swapped by mistake
Value default_value,
bool check_type,
bool detailed) {
Expand Down Expand Up @@ -302,7 +300,7 @@

LD_ASSERT(desc->item);

auto const& flag = *(desc->item);

Check warning on line 303 in libs/client-sdk/src/client_impl.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/client-sdk/src/client_impl.cpp:303:25 [bugprone-unchecked-optional-access]

unchecked access to optional value
auto const& detail = flag.Detail();

// The Prerequisites vector represents the evaluated prerequisites of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ struct Date {
struct TrackEventParams {
Date creation_date;
std::string key;
ContextKeys context_keys;
Context context;
std::optional<Value> data;
std::optional<double> metric_value;
};

struct ServerTrackEventParams {
TrackEventParams base;
Context context;
struct TrackEvent {
Date creation_date;
std::string key;
EventContext context;
std::optional<Value> data;
std::optional<double> metric_value;
};

using ClientTrackEventParams = TrackEventParams;

using TrackEvent = TrackEventParams;

struct IdentifyEventParams {
Date creation_date;
Context context;
Expand Down
7 changes: 3 additions & 4 deletions libs/internal/include/launchdarkly/events/data/events.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#pragma once

#include <launchdarkly/events/data/common_events.hpp>

Check failure on line 3 in libs/internal/include/launchdarkly/events/data/events.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/libs/internal/include/launchdarkly/events/data/events.hpp:3:10 [clang-diagnostic-error]

'launchdarkly/events/data/common_events.hpp' file not found
#include <launchdarkly/events/data/server_events.hpp>

#include <variant>
#include "common_events.hpp"

namespace launchdarkly::events {

using InputEvent = std::variant<FeatureEventParams,
IdentifyEventParams,
ClientTrackEventParams,
ServerTrackEventParams>;
using InputEvent =
std::variant<FeatureEventParams, IdentifyEventParams, TrackEventParams>;

using OutputEvent = std::variant<FeatureEvent,
DebugEvent,
Expand Down
15 changes: 9 additions & 6 deletions libs/internal/src/events/asio_event_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,24 @@ std::vector<OutputEvent> AsioEventProcessor<SDK>::Process(
out.emplace_back(IdentifyEvent{event.creation_date,
filter_.Filter(event.context)});
},
[&](ClientTrackEventParams&& event) {
out.emplace_back(std::move(event));
},
[&](ServerTrackEventParams&& event) {
[&](TrackEventParams&& event) {
if constexpr (std::is_same<SDK,
config::shared::ServerSDK>::value) {
if (!context_key_cache_.Notice(
event.context.CanonicalKey())) {
out.emplace_back(server_side::IndexEvent{
event.base.creation_date,
event.creation_date,
filter_.Filter(event.context)});
}
}

out.emplace_back(std::move(event.base));
out.emplace_back(TrackEvent{
event.creation_date,
event.key,
filter_.Filter(event.context),
event.data,
event.metric_value,
});
}},
std::move(input_event));

Expand Down
4 changes: 2 additions & 2 deletions libs/internal/src/serialization/events/json_events.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <launchdarkly/detail/serialization/json_value.hpp>
#include <launchdarkly/serialization/events/json_events.hpp>
#include <launchdarkly/serialization/json_evaluation_reason.hpp>
#include <launchdarkly/detail/serialization/json_value.hpp>

namespace launchdarkly::events {
void tag_invoke(boost::json::value_from_tag const& tag,
Expand Down Expand Up @@ -83,7 +83,7 @@ void tag_invoke(boost::json::value_from_tag const& tag,
obj.emplace("kind", "custom");
obj.emplace("creationDate", boost::json::value_from(event.creation_date));
obj.emplace("key", event.key);
obj.emplace("contextKeys", boost::json::value_from(event.context_keys));
obj.emplace("context", event.context);
if (event.data) {
obj.emplace("data", boost::json::value_from(*event.data));
}
Expand Down
7 changes: 3 additions & 4 deletions libs/server-sdk/src/events/event_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ events::InputEvent EventFactory::Custom(
std::string event_name,
std::optional<Value> data,
std::optional<double> metric_value) const {
return events::ServerTrackEventParams{
{now_(), std::move(event_name), ctx.KindsToKeys(), std::move(data),
metric_value},
ctx};
return events::TrackEventParams{now_(), std::move(event_name),
std::move(ctx), std::move(data),
metric_value};
}

events::InputEvent EventFactory::FeatureRequest(
Expand Down
2 changes: 1 addition & 1 deletion libs/server-sdk/tests/event_scope_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ TEST(EventScope, ForwardsCorrectEventTypes) {
ASSERT_TRUE(processor.Kind<events::IdentifyEventParams>(0));
ASSERT_TRUE(processor.Kind<events::FeatureEventParams>(1));
ASSERT_TRUE(processor.Kind<events::FeatureEventParams>(2));
ASSERT_TRUE(processor.Kind<events::ServerTrackEventParams>(3));
ASSERT_TRUE(processor.Kind<events::TrackEventParams>(3));
}
Loading