Skip to content

Commit

Permalink
Merge branch 'server-side' into rlamb/common-persistent-store
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Sep 15, 2023
2 parents 20abc69 + 61a3bef commit d3730a8
Show file tree
Hide file tree
Showing 31 changed files with 523 additions and 228 deletions.
30 changes: 30 additions & 0 deletions .github/actions/sdk-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ inputs:
required: true
sdk_cmake_target:
description: 'CMake target of the sdk, e.g. launchdarkly-cpp-client.'
outputs:
hashes-linux:
description: "base64-encoded sha256 hash of linux build artifacts"
value: ${{ steps.hash-linux.outputs.hashes-linux }}
hashes-windows:
description: "base64-encoded sha256 hash of windows build artifacts"
value: ${{ steps.hash-windows.outputs.hashes-windows }}
hashes-macos:
description: "base64-encoded sha256 hash of macos build artifacts"
value: ${{ steps.hash-macos.outputs.hashes-macos }}

runs:
using: composite
Expand Down Expand Up @@ -56,6 +66,12 @@ runs:
type: 'zip'
filename: 'linux-gcc-x64-dynamic.zip'

- name: Hash Linux Build Artifacts for provenance
if: runner.os == 'Linux'
shell: bash
id: hash-linux
run: |
echo "hashes-linux=$(sha256sum linux-gcc-x64-static.zip linux-gcc-x64-dynamic.zip | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Upload Linux Build Artifacts
if: runner.os == 'Linux'
Expand Down Expand Up @@ -118,6 +134,13 @@ runs:
type: 'zip'
filename: 'windows-msvc-x64-dynamic-debug.zip'

- name: Hash Windows Build Artifacts for provenance
if: runner.os == 'Windows'
shell: bash
id: hash-windows
run: |
echo "hashes-windows=$(sha256sum windows-msvc-x64-static.zip windows-msvc-x64-dynamic.zip windows-msvc-x64-static-debug.zip windows-msvc-x64-dynamic-debug.zip | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Upload Windows Build Artifacts
if: runner.os == 'Windows'
shell: bash
Expand Down Expand Up @@ -157,6 +180,13 @@ runs:
type: 'zip'
filename: 'mac-clang-x64-dynamic.zip'

- name: Hash Mac Build Artifacts for provenance
if: runner.os == 'macOS'
shell: bash
id: hash-macos
run: |
echo "hashes-macos=$(shasum -a 256 mac-clang-x64-static.zip mac-clang-x64-dynamic.zip | base64 -b 0)" >> "$GITHUB_OUTPUT"
- name: Upload Mac Build Artifacts
if: runner.os == 'macOS'
shell: bash
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/manual-sdk-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
# Each of the platforms for which release-artifacts need generated.
os: [ ubuntu-latest, windows-2022, macos-12 ]
runs-on: ${{ matrix.os }}
outputs:
hashes-linux: ${{ steps.release-sdk.outputs.hashes-linux }}
hashes-windows: ${{ steps.release-sdk.outputs.hashes-windows }}
hashes-macos: ${{ steps.release-sdk.outputs.hashes-macos }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -50,3 +54,19 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
sdk_path: ${{ needs.split-input.outputs.sdk_path}}
sdk_cmake_target: ${{ needs.split-input.outputs.sdk_cmake_target}}
release-sdk-provenance:
needs: ['release-sdk']
strategy:
matrix:
# Generates a combined attestation for each platform
os: [ linux, windows, macos ]
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.release-sdk.outputs[format('hashes-{0}', matrix.os)] }}"
upload-assets: true
upload-tag-name: ${{ inputs.tag }}
provenance-name: ${{ format('{0}-multiple-provenance.intoto.jsonl', matrix.os) }}
21 changes: 21 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
runs-on: ${{ matrix.os }}
needs: [ 'release-please' ]
if: ${{ needs.release-please.outputs.package-client-released }}
outputs:
hashes-linux: ${{ steps.release-client.outputs.hashes-linux }}
hashes-windows: ${{ steps.release-client.outputs.hashes-windows }}
hashes-macos: ${{ steps.release-client.outputs.hashes-macos }}
steps:
- uses: actions/checkout@v3
- id: release-client
Expand All @@ -37,3 +41,20 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
sdk_path: 'libs/client-sdk'
sdk_cmake_target: 'launchdarkly-cpp-client'

release-client-provenance:
needs: ['release-please', 'release-client']
strategy:
matrix:
# Generates a combined attestation for each platform
os: [ linux, windows, macos ]
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
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-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.6",
"libs/server-sent-events": "0.1.1",
"libs/common": "0.3.4",
"libs/internal": "0.1.7"
"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
31 changes: 31 additions & 0 deletions libs/client-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

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)


### Bug Fixes

* allow for specification of initial reconnect delay in streaming data source ([#229](https://github.com/launchdarkly/cpp-sdks/issues/229)) ([d1dde79](https://github.com/launchdarkly/cpp-sdks/commit/d1dde79fde80cc32e19cf384140e138ce64ca02b))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* launchdarkly-cpp-internal bumped from 0.1.7 to 0.1.8
* launchdarkly-cpp-common bumped from 0.3.4 to 0.3.5

## [3.0.6](https://github.com/launchdarkly/cpp-sdks/compare/launchdarkly-cpp-client-v3.0.5...launchdarkly-cpp-client-v3.0.6) (2023-08-29)


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.6 # {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.6"; // {x-release-please-version}
"3.0.8"; // {x-release-please-version}
std::unique_ptr<IClient> client;
};

Expand Down
7 changes: 4 additions & 3 deletions libs/client-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "launchdarkly-cpp-client",
"description": "This package.json exists for modeling dependencies for the release process.",
"version": "3.0.6",
"version": "3.0.8",
"private": true,
"dependencies": {
"launchdarkly-cpp-internal": "0.1.7",
"launchdarkly-cpp-common": "0.3.4"
"launchdarkly-cpp-internal": "0.1.9",
"launchdarkly-cpp-common": "0.3.6",
"launchdarkly-cpp-sse-client": "0.1.3"
}
}
Loading

0 comments on commit d3730a8

Please sign in to comment.