Skip to content

Commit

Permalink
Merge branch 'main' into server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Sep 14, 2023
2 parents 5f04888 + dd4b5a6 commit fe9e559
Show file tree
Hide file tree
Showing 26 changed files with 287 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual-sdk-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:
base64-subjects: "${{ needs.release-sdk.outputs[format('hashes-{0}', matrix.os)] }}"
upload-assets: true
upload-tag-name: ${{ inputs.tag }}
provenance-name: ${{ format('{0}-multiple.intoto.jsonl', matrix.os) }}
provenance-name: ${{ format('{0}-multiple-provenance.intoto.jsonl', matrix.os) }}
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
sdk_cmake_target: 'launchdarkly-cpp-client'

release-client-provenance:
needs: ['release-client']
needs: ['release-please', 'release-client']
strategy:
matrix:
# Generates a combined attestation for each platform
Expand All @@ -57,4 +57,4 @@ jobs:
base64-subjects: "${{ needs.release-client.outputs[format('hashes-{0}', matrix.os)] }}"
upload-assets: true
upload-tag-name: ${{ needs.release-please.outputs.package-client-tag }}
provenance-name: ${{ format('{0}-multiple.intoto.jsonl', matrix.os) }}
provenance-name: ${{ format('{0}-multiple-provenance.intoto.jsonl', matrix.os) }}
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"libs/client-sdk": "3.0.7",
"libs/server-sent-events": "0.1.2",
"libs/common": "0.3.5",
"libs/internal": "0.1.8"
"libs/client-sdk": "3.0.8",
"libs/server-sent-events": "0.1.3",
"libs/common": "0.3.6",
"libs/internal": "0.1.9"
}
4 changes: 2 additions & 2 deletions contract-tests/sse-contract-tests/include/event_outbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class EventOutbox : public std::enable_shared_from_this<EventOutbox> {
private:
RequestType build_request(
std::size_t counter,
std::variant<launchdarkly::sse::Event, launchdarkly::sse::Error> ev);
std::variant<launchdarkly::sse::Event, launchdarkly::sse::Error> event);
void on_resolve(beast::error_code ec, tcp::resolver::results_type results);
void on_connect(beast::error_code ec,
tcp::resolver::results_type::endpoint_type);
void on_flush_timer(boost::system::error_code ec);
void on_write(beast::error_code ec, std::size_t);
void do_shutdown(beast::error_code ec, std::string what);
void do_shutdown(beast::error_code ec);
};
18 changes: 12 additions & 6 deletions contract-tests/sse-contract-tests/src/entity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,30 @@ std::optional<std::string> EntityManager::create(ConfigParams const& params) {
}

if (params.body) {
client_builder.body(std::move(*params.body));
client_builder.body(*params.body);
}

if (params.readTimeoutMs) {
client_builder.read_timeout(
std::chrono::milliseconds(*params.readTimeoutMs));
}

if (params.initialDelayMs) {
client_builder.initial_reconnect_delay(
std::chrono::milliseconds(*params.initialDelayMs));
}

client_builder.logger([this](std::string msg) {
LD_LOG(logger_, LogLevel::kDebug) << std::move(msg);
});

client_builder.receiver([copy = poster](launchdarkly::sse::Event e) {
copy->post_event(std::move(e));
client_builder.receiver([copy = poster](launchdarkly::sse::Event event) {
copy->post_event(std::move(event));
});

client_builder.errors(
[copy = poster](launchdarkly::sse::Error e) { copy->post_error(e); });
client_builder.errors([copy = poster](launchdarkly::sse::Error event) {
copy->post_error(event);
});

auto client = client_builder.build();
if (!client) {
Expand All @@ -53,7 +59,7 @@ std::optional<std::string> EntityManager::create(ConfigParams const& params) {
return std::nullopt;
}

client->run();
client->async_connect();

entities_.emplace(id, std::make_pair(client, poster));
return id;
Expand Down
26 changes: 12 additions & 14 deletions contract-tests/sse-contract-tests/src/event_outbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ auto const kOutboxCapacity = 1023;
EventOutbox::EventOutbox(net::any_io_executor executor,
std::string callback_url)
: callback_url_{std::move(callback_url)},
callback_port_{},
callback_host_{},
callback_counter_{0},
executor_{executor},
resolver_{executor},
Expand All @@ -29,7 +27,7 @@ EventOutbox::EventOutbox(net::any_io_executor executor,
callback_port_ = uri_components->port();
}

void EventOutbox::do_shutdown(beast::error_code ec, std::string what) {
void EventOutbox::do_shutdown(beast::error_code ec) {
event_stream_.socket().shutdown(tcp::socket::shutdown_both, ec);
flush_timer_.cancel();
}
Expand All @@ -54,20 +52,18 @@ void EventOutbox::run() {

void EventOutbox::stop() {
beast::error_code ec = net::error::basic_errors::operation_aborted;
std::string reason = "stop";
shutdown_ = true;
net::post(executor_,
beast::bind_front_handler(&EventOutbox::do_shutdown,
shared_from_this(), ec, reason));
net::post(executor_, beast::bind_front_handler(&EventOutbox::do_shutdown,
shared_from_this(), ec));
}

EventOutbox::RequestType EventOutbox::build_request(
std::size_t counter,
std::variant<launchdarkly::sse::Event, launchdarkly::sse::Error> ev) {
std::variant<launchdarkly::sse::Event, launchdarkly::sse::Error> event) {
RequestType req;

req.set(http::field::host, callback_host_);
req.method(http::verb::get);
req.method(http::verb::post);
req.target(callback_url_ + "/" + std::to_string(counter));

nlohmann::json json;
Expand All @@ -93,13 +89,15 @@ EventOutbox::RequestType EventOutbox::build_request(
break;
case Error::UnrecoverableClientError:
msg.comment = "unrecoverable client error";
case Error::ReadTimeout:
msg.comment = "read timeout";
default:
msg.comment = "unspecified error";
}
json = msg;
}
},
std::move(ev));
std::move(event));

req.body() = json.dump();
req.prepare_payload();
Expand All @@ -109,7 +107,7 @@ EventOutbox::RequestType EventOutbox::build_request(
void EventOutbox::on_resolve(beast::error_code ec,
tcp::resolver::results_type results) {
if (ec) {
return do_shutdown(ec, "resolve");
return do_shutdown(ec);
}

beast::get_lowest_layer(event_stream_)
Expand All @@ -121,7 +119,7 @@ void EventOutbox::on_resolve(beast::error_code ec,
void EventOutbox::on_connect(beast::error_code ec,
tcp::resolver::results_type::endpoint_type) {
if (ec) {
return do_shutdown(ec, "connect");
return do_shutdown(ec);
}

boost::system::error_code dummy;
Expand All @@ -131,7 +129,7 @@ void EventOutbox::on_connect(beast::error_code ec,

void EventOutbox::on_flush_timer(boost::system::error_code ec) {
if (ec && shutdown_) {
return do_shutdown(ec, "flush");
return do_shutdown(ec);
}

if (!outbox_.empty()) {
Expand All @@ -154,7 +152,7 @@ void EventOutbox::on_flush_timer(boost::system::error_code ec) {

void EventOutbox::on_write(beast::error_code ec, std::size_t) {
if (ec) {
return do_shutdown(ec, "write");
return do_shutdown(ec);
}
outbox_.pop();
on_flush_timer(boost::system::error_code{});
Expand Down
3 changes: 2 additions & 1 deletion contract-tests/sse-contract-tests/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
launchdarkly::Logger logger{
std::make_unique<ConsoleBackend>("sse-contract-tests")};

const std::string default_port = "8123";
std::string const default_port = "8123";
std::string port = default_port;
if (argc == 2) {
port =
Expand All @@ -38,6 +38,7 @@ int main(int argc, char* argv[]) {
srv.add_capability("report");
srv.add_capability("post");
srv.add_capability("reconnection");
srv.add_capability("read-timeout");

net::signal_set signals{ioc, SIGINT, SIGTERM};

Expand Down
16 changes: 16 additions & 0 deletions libs/client-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to the LaunchDarkly Client-Side SDK for C/C++ will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).

## [3.0.8](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-client-v3.0.7...launchdarkly-cpp-client-v3.0.8) (2023-09-13)


### Bug Fixes

* stream connections longer than 5 minutes are dropped ([#244](https://github.com/launchdarkly/cpp-sdks/issues/244)) ([e12664f](https://github.com/launchdarkly/cpp-sdks/commit/e12664f830c84c17242fe9f032d570796555f3d1))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-internal bumped from 0.1.8 to 0.1.9
* launchdarkly-cpp-common bumped from 0.3.5 to 0.3.6
* launchdarkly-cpp-sse-client bumped from 0.1.2 to 0.1.3

## [3.0.7](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-client-v3.0.6...launchdarkly-cpp-client-v3.0.7) (2023-08-31)


Expand Down
2 changes: 1 addition & 1 deletion libs/client-sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.19)

project(
LaunchDarklyCPPClient
VERSION 3.0.7 # {x-release-please-version}
VERSION 3.0.8 # {x-release-please-version}
DESCRIPTION "LaunchDarkly C++ Client SDK"
LANGUAGES CXX C
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class Client : public IClient {

private:
inline static char const* const kVersion =
"3.0.7"; // {x-release-please-version}
"3.0.8"; // {x-release-please-version}
std::unique_ptr<IClient> client;
};

Expand Down
8 changes: 4 additions & 4 deletions libs/client-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "launchdarkly-cpp-client",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "3.0.7",
"version": "3.0.8",
"private": true,
"dependencies": {
"launchdarkly-cpp-internal": "0.1.8",
"launchdarkly-cpp-common": "0.3.5",
"launchdarkly-cpp-sse-client": "0.1.2"
"launchdarkly-cpp-internal": "0.1.9",
"launchdarkly-cpp-common": "0.3.6",
"launchdarkly-cpp-sse-client": "0.1.3"
}
}
6 changes: 4 additions & 2 deletions libs/client-sdk/src/data_sources/streaming_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static char const* DataSourceErrorToString(launchdarkly::sse::Error error) {
return "server responded with an invalid redirection";
case sse::Error::UnrecoverableClientError:
return "unrecoverable client-side error";
case sse::Error::ReadTimeout:
return "read timeout reached";
}
}

Expand Down Expand Up @@ -138,7 +140,7 @@ void StreamingDataSource::Start() {

client_builder.logger([weak_self](auto msg) {
if (auto self = weak_self.lock()) {
LD_LOG(self->logger_, LogLevel::kDebug) << msg;
LD_LOG(self->logger_, LogLevel::kDebug) << "sse-client: " << msg;
}
});

Expand All @@ -163,7 +165,7 @@ void StreamingDataSource::Start() {
kCouldNotParseEndpoint);
return;
}
client_->run();
client_->async_connect();
}

void StreamingDataSource::ShutdownAsync(std::function<void()> completion) {
Expand Down
2 changes: 1 addition & 1 deletion libs/client-sdk/tests/client_c_bindings_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST(ClientBindings, MinimalInstantiation) {

char const* version = LDClientSDK_Version();
ASSERT_TRUE(version);
ASSERT_STREQ(version, "3.0.7"); // {x-release-please-version}
ASSERT_STREQ(version, "3.0.8"); // {x-release-please-version}

LDClientSDK_Free(sdk);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/client-sdk/tests/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(ClientTest, ClientConstructedWithMinimalConfigAndContext) {

char const* version = client.Version();
ASSERT_TRUE(version);
ASSERT_STREQ(version, "3.0.7"); // {x-release-please-version}
ASSERT_STREQ(version, "3.0.8"); // {x-release-please-version}
}

TEST(ClientTest, AllFlagsIsEmpty) {
Expand Down
7 changes: 7 additions & 0 deletions libs/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* dependencies
* launchdarkly-cpp-sse-client bumped from 0.1.1 to 0.1.2

## [0.3.6](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-common-v0.3.5...launchdarkly-cpp-common-v0.3.6) (2023-09-13)


### Bug Fixes

* stream connections longer than 5 minutes are dropped ([#244](https://github.com/launchdarkly/cpp-sdks/issues/244)) ([e12664f](https://github.com/launchdarkly/cpp-sdks/commit/e12664f830c84c17242fe9f032d570796555f3d1))

## [0.3.4](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-common-v0.3.3...launchdarkly-cpp-common-v0.3.4) (2023-08-28)


Expand Down
2 changes: 1 addition & 1 deletion libs/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "launchdarkly-cpp-common",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "0.3.5",
"version": "0.3.6",
"private": true
}
4 changes: 3 additions & 1 deletion libs/common/src/config/logging_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ LoggingBuilder::BasicLogging& LoggingBuilder::BasicLogging::Tag(
return *this;
}
LoggingBuilder::BasicLogging::BasicLogging()
: level_(Defaults<AnySDK>::LogLevel()), tag_(Defaults<AnySDK>::LogTag()) {}
: level_(GetLogLevelEnum(std::getenv("LD_LOG_LEVEL"),
Defaults<AnySDK>::LogLevel())),
tag_(Defaults<AnySDK>::LogTag()) {}

LoggingBuilder::CustomLogging& LoggingBuilder::CustomLogging::Backend(
std::shared_ptr<ILogBackend> backend) {
Expand Down
6 changes: 6 additions & 0 deletions libs/internal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
* dependencies
* launchdarkly-cpp-common bumped from 0.3.4 to 0.3.5

### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-common bumped from 0.3.5 to 0.3.6

## [0.1.5](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-internal-v0.1.4...launchdarkly-cpp-internal-v0.1.5) (2023-06-30)


Expand Down
4 changes: 2 additions & 2 deletions libs/internal/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "launchdarkly-cpp-internal",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "0.1.8",
"version": "0.1.9",
"private": true,
"dependencies": {
"launchdarkly-cpp-common": "0.3.5"
"launchdarkly-cpp-common": "0.3.6"
}
}
7 changes: 7 additions & 0 deletions libs/server-sent-events/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.1.3](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-sse-client-v0.1.2...launchdarkly-cpp-sse-client-v0.1.3) (2023-09-13)


### Bug Fixes

* stream connections longer than 5 minutes are dropped ([#244](https://github.com/launchdarkly/cpp-sdks/issues/244)) ([e12664f](https://github.com/launchdarkly/cpp-sdks/commit/e12664f830c84c17242fe9f032d570796555f3d1))

## [0.1.2](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-sse-client-v0.1.1...launchdarkly-cpp-sse-client-v0.1.2) (2023-08-31)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Builder {
class Client {
public:
virtual ~Client() = default;
virtual void run() = 0;
virtual void async_connect() = 0;
virtual void async_shutdown(std::function<void()> completion) = 0;
};

Expand Down
1 change: 1 addition & 0 deletions libs/server-sent-events/include/launchdarkly/sse/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ enum class Error {
NoContent = 1,
InvalidRedirectLocation = 2,
UnrecoverableClientError = 3,
ReadTimeout = 4,
};
}
Loading

0 comments on commit fe9e559

Please sign in to comment.