Skip to content

Commit

Permalink
Merge branch 'main' into rlamb/sc-251111/stream-close-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Jul 24, 2024
2 parents a2fda98 + 8b6913d commit 70b49cd
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
package-server-redis-released: ${{ steps.release.outputs['libs/server-sdk-redis-source--release_created'] }}
package-server-redis-tag: ${{ steps.release.outputs['libs/server-sdk-redis-source--tag_name'] }}
steps:
- uses: google-github-actions/release-please-action@v4
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"libs/client-sdk": "3.6.1",
"libs/server-sent-events": "0.5.0",
"libs/client-sdk": "3.6.2",
"libs/server-sent-events": "0.5.1",
"libs/common": "1.7.0",
"libs/internal": "0.8.1",
"libs/server-sdk": "3.5.1",
"libs/server-sdk-redis-source": "2.1.9"
"libs/server-sdk": "3.5.2",
"libs/server-sdk-redis-source": "2.1.10"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Various CMake options are available to customize the client/server SDK builds.
**Note:** _if building the SDKs as shared libraries, then unit tests won't be able to link correctly since the SDK's C++
symbols aren't exposed. To run unit tests, build a static library._

> [!WARNING]
> When building shared libraries C++ symbols are not exported, only the C API will be exported. This is because C++ does not have a stable ABI.
Basic usage example:

```bash
Expand Down
22 changes: 5 additions & 17 deletions contract-tests/sse-contract-tests/src/event_outbox.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "event_outbox.hpp"
#include "definitions.hpp"

#include <boost/beast/core/bind_handler.hpp>
#include <boost/url/parse.hpp>
#include <iostream>
#include <nlohmann/json.hpp>

#include <iostream>

// Check the outbox at this interval. Normally a flush is triggered for
// every event; this is just a failsafe in case a flush is happening
// concurrently.
Expand Down Expand Up @@ -78,22 +80,8 @@ EventOutbox::RequestType EventOutbox::build_request(
json = EventMessage{"event", Event{std::move(arg)}};
}
} else if constexpr (std::is_same_v<T, launchdarkly::sse::Error>) {
using launchdarkly::sse::Error;
auto msg = ErrorMessage{"error"};
switch (arg) {
case Error::NoContent:
msg.comment = "no content";
break;
case Error::InvalidRedirectLocation:
msg.comment = "invalid redirect location";
break;
case Error::UnrecoverableClientError:
msg.comment = "unrecoverable client error";
case Error::ReadTimeout:
msg.comment = "read timeout";
default:
msg.comment = "unspecified error";
}
auto msg = ErrorMessage{"error",
launchdarkly::sse::ErrorToString(arg)};
json = msg;
}
},
Expand Down
14 changes: 14 additions & 0 deletions libs/client-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [3.6.2](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-client-v3.6.1...launchdarkly-cpp-client-v3.6.2) (2024-07-15)


### Bug Fixes

* more helpful error messages for streaming connection failures ([#419](https://github.com/launchdarkly/cpp-sdks/issues/419)) ([6bd21ba](https://github.com/launchdarkly/cpp-sdks/commit/6bd21ba1eafb5f19275935e1f62f7304d4dc69f5))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-sse-client bumped from 0.5.0 to 0.5.1

## [3.6.1](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-client-v3.6.0...launchdarkly-cpp-client-v3.6.1) (2024-06-11)


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.6.1 # {x-release-please-version}
VERSION 3.6.2 # {x-release-please-version}
DESCRIPTION "LaunchDarkly C++ Client SDK"
LANGUAGES CXX C
)
Expand Down
16 changes: 14 additions & 2 deletions libs/client-sdk/include/launchdarkly/client_side/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace launchdarkly::client_side {

/**
* Interface for the standard SDK client methods and properties.
*
* After an SDK instance is created it should be started with the StartAsync
* method. Subsequently if a change of context is required the IdentifyAsync
* method should be used.
*/
class IClient {
public:
Expand All @@ -28,7 +32,11 @@ class IClient {

/** Connects the client to LaunchDarkly's flag delivery endpoints.
*
* StartAsync must be called to obtain fresh flag data.
* StartAsync must be called once for the SDK to start receiving flag data.
* StartAsync only needs to be called one time for the lifetime of the SDK
* client.
* To change the context associated with evaluations please call the
* IdentifyAsync method.
*
* The returned future will resolve to true or false based on the logic
* outlined on @ref Initialized.
Expand All @@ -42,6 +50,10 @@ class IClient {
*
* While the client is connecting asynchronously, it is safe to call
* variation methods, which will return application-defined default values.
*
* The client will always continue to attempt to connect asynchronously
* after being started unless it encounters an unrecoverable error. The
* returned promise timing out does not affect this behavior.
*/
virtual std::future<bool> StartAsync() = 0;

Expand Down Expand Up @@ -333,7 +345,7 @@ class Client : public IClient {

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

Expand Down
4 changes: 2 additions & 2 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.6.1",
"version": "3.6.2",
"private": true,
"dependencies": {
"launchdarkly-cpp-internal": "0.8.1",
"launchdarkly-cpp-common": "1.7.0",
"launchdarkly-cpp-sse-client": "0.5.0"
"launchdarkly-cpp-sse-client": "0.5.1"
}
}
19 changes: 2 additions & 17 deletions libs/client-sdk/src/data_sources/streaming_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ namespace launchdarkly::client_side::data_sources {
static char const* const kCouldNotParseEndpoint =
"Could not parse streaming endpoint URL.";

static char const* DataSourceErrorToString(launchdarkly::sse::Error error) {
switch (error) {
case sse::Error::NoContent:
return "server responded 204 (No Content), will not attempt to "
"reconnect";
case sse::Error::InvalidRedirectLocation:
return "server responded with an invalid redirection";
case sse::Error::UnrecoverableClientError:
return "unrecoverable client-side error";
case sse::Error::ReadTimeout:
return "read timeout reached";
}
launchdarkly::detail::unreachable();
}

StreamingDataSource::StreamingDataSource(
config::shared::built::ServiceEndpoints const& endpoints,
config::shared::built::DataSourceConfig<config::shared::ClientSDK> const&
Expand Down Expand Up @@ -155,12 +140,12 @@ void StreamingDataSource::Start() {

client_builder.errors([weak_self](auto error) {
if (auto self = weak_self.lock()) {
auto error_string = DataSourceErrorToString(error);
auto error_string = launchdarkly::sse::ErrorToString(error);
LD_LOG(self->logger_, LogLevel::kError) << error_string;
self->status_manager_.SetState(
DataSourceStatus::DataSourceState::kShutdown,
DataSourceStatus::ErrorInfo::ErrorKind::kErrorResponse,
error_string);
std::move(error_string));
}
});

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.6.1"); // {x-release-please-version}
ASSERT_STREQ(version, "3.6.2"); // {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.6.1"); // {x-release-please-version}
ASSERT_STREQ(version, "3.6.2"); // {x-release-please-version}
}

TEST(ClientTest, AllFlagsIsEmpty) {
Expand Down
9 changes: 9 additions & 0 deletions libs/server-sdk-redis-source/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [2.1.10](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-server-redis-source-v2.1.9...launchdarkly-cpp-server-redis-source-v2.1.10) (2024-07-15)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-server bumped from 3.5.1 to 3.5.2

## [2.1.9](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-server-redis-source-v2.1.8...launchdarkly-cpp-server-redis-source-v2.1.9) (2024-06-11)


Expand Down
2 changes: 1 addition & 1 deletion libs/server-sdk-redis-source/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(
LaunchDarklyCPPServerRedisSource
VERSION 2.1.9 # {x-release-please-version}
VERSION 2.1.10 # {x-release-please-version}
DESCRIPTION "LaunchDarkly C++ Server SDK Redis Source"
LANGUAGES CXX C
)
Expand Down
4 changes: 2 additions & 2 deletions libs/server-sdk-redis-source/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "launchdarkly-cpp-server-redis-source",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "2.1.9",
"version": "2.1.10",
"private": true,
"dependencies": {
"launchdarkly-cpp-server": "3.5.1"
"launchdarkly-cpp-server": "3.5.2"
}
}
14 changes: 14 additions & 0 deletions libs/server-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [3.5.2](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-server-v3.5.1...launchdarkly-cpp-server-v3.5.2) (2024-07-15)


### Bug Fixes

* more helpful error messages for streaming connection failures ([#419](https://github.com/launchdarkly/cpp-sdks/issues/419)) ([6bd21ba](https://github.com/launchdarkly/cpp-sdks/commit/6bd21ba1eafb5f19275935e1f62f7304d4dc69f5))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-sse-client bumped from 0.5.0 to 0.5.1

## [3.5.1](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-server-v3.5.0...launchdarkly-cpp-server-v3.5.1) (2024-06-11)


Expand Down
2 changes: 1 addition & 1 deletion libs/server-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(
LaunchDarklyCPPServer
VERSION 3.5.1 # {x-release-please-version}
VERSION 3.5.2 # {x-release-please-version}
DESCRIPTION "LaunchDarkly C++ Server SDK"
LANGUAGES CXX C
)
Expand Down
9 changes: 7 additions & 2 deletions libs/server-sdk/include/launchdarkly/server_side/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class IClient {

/** Connects the client to LaunchDarkly's flag delivery endpoints.
*
* StartAsync must be called to obtain fresh flag data.
* StartAsync must be called once for the SDK to start receiving flag data.
* It does not need to be called more than one time.
*
* The returned future will resolve to true or false based on the logic
* outlined on @ref Initialized.
Expand All @@ -41,6 +42,10 @@ class IClient {
*
* While the client is connecting asynchronously, it is safe to call
* variation methods, which will return application-defined default values.
*
* The client will always continue to attempt to connect asynchronously
* after being started unless it encounters an unrecoverable error. The
* returned promise timing out does not affect this behavior.
*/
virtual std::future<bool> StartAsync() = 0;

Expand Down Expand Up @@ -355,7 +360,7 @@ class Client : public IClient {

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

Expand Down
4 changes: 2 additions & 2 deletions libs/server-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "launchdarkly-cpp-server",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "3.5.1",
"version": "3.5.2",
"private": true,
"dependencies": {
"launchdarkly-cpp-internal": "0.8.1",
"launchdarkly-cpp-common": "1.7.0",
"launchdarkly-cpp-sse-client": "0.5.0"
"launchdarkly-cpp-sse-client": "0.5.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ namespace launchdarkly::server_side::data_systems {
static char const* const kCouldNotParseEndpoint =
"Could not parse streaming endpoint URL";

static char const* DataSourceErrorToString(sse::Error const error) {
switch (error) {
case sse::Error::NoContent:
return "server responded 204 (No Content), will not attempt to "
"reconnect";
case sse::Error::InvalidRedirectLocation:
return "server responded with an invalid redirection";
case sse::Error::UnrecoverableClientError:
return "unrecoverable client-side error";
default:
return "unrecognized error";
}
}

std::string const& StreamingDataSource::Identity() const {
static std::string const identity = "streaming data source";
return identity;
Expand Down Expand Up @@ -132,12 +118,12 @@ void StreamingDataSource::StartAsync(

client_builder.errors([weak_self](auto error) {
if (auto self = weak_self.lock()) {
auto error_string = DataSourceErrorToString(error);
std::string error_string = launchdarkly::sse::ErrorToString(error);
LD_LOG(self->logger_, LogLevel::kError) << error_string;
self->status_manager_.SetState(
DataSourceStatus::DataSourceState::kOff,
DataSourceStatus::ErrorInfo::ErrorKind::kErrorResponse,
error_string);
std::move(error_string));
}
});

Expand Down
2 changes: 1 addition & 1 deletion libs/server-sdk/tests/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ClientTest : public ::testing::Test {
TEST_F(ClientTest, ClientConstructedWithMinimalConfigAndContextT) {
char const* version = client_.Version();
ASSERT_TRUE(version);
ASSERT_STREQ(version, "3.5.1"); // {x-release-please-version}
ASSERT_STREQ(version, "3.5.2"); // {x-release-please-version}
}

TEST_F(ClientTest, BoolVariationDefaultPassesThrough) {
Expand Down
2 changes: 1 addition & 1 deletion libs/server-sdk/tests/server_c_bindings_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST(ClientBindings, MinimalInstantiation) {

char const* version = LDServerSDK_Version();
ASSERT_TRUE(version);
ASSERT_STREQ(version, "3.5.1"); // {x-release-please-version}
ASSERT_STREQ(version, "3.5.2"); // {x-release-please-version}

LDServerSDK_Free(sdk);
}
Expand Down
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.5.1](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-sse-client-v0.5.0...launchdarkly-cpp-sse-client-v0.5.1) (2024-07-15)


### Bug Fixes

* more helpful error messages for streaming connection failures ([#419](https://github.com/launchdarkly/cpp-sdks/issues/419)) ([6bd21ba](https://github.com/launchdarkly/cpp-sdks/commit/6bd21ba1eafb5f19275935e1f62f7304d4dc69f5))

## [0.5.0](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-sse-client-v0.4.0...launchdarkly-cpp-sse-client-v0.5.0) (2024-05-30)


Expand Down
Loading

0 comments on commit 70b49cd

Please sign in to comment.