Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
beb76b5
add foxy library
cwaldren-ld May 2, 2023
37f21e4
update read timeouts
cwaldren-ld May 2, 2023
75cafe1
refactor timeouts
cwaldren-ld May 2, 2023
1341857
move everything back to milliseconds; update foxy method
cwaldren-ld May 3, 2023
717d330
Merge branch 'main' into cw/sc-199702/foxy-eventsource
cwaldren-ld May 3, 2023
b1a63d7
remove ability to shutdown streaming event source
cwaldren-ld May 3, 2023
c28e803
broken trying to fix AsioRequestor to use foxy
cwaldren-ld May 3, 2023
87306b1
Merge branch 'main' into cw/sc-199702/foxy-eventsource
cwaldren-ld May 4, 2023
35e67b4
Revert "broken trying to fix AsioRequestor to use foxy"
cwaldren-ld May 4, 2023
4602fef
point to launchdarkly/foxy repo
cwaldren-ld May 4, 2023
4b32c99
update to read SSE body only on successful HTTP response
cwaldren-ld May 4, 2023
98e4d3e
get asio requester working with foxy; remove Encrypted/Plain clients
cwaldren-ld May 5, 2023
f9c5eac
remove certify.cmake in favor of foxy::certify
cwaldren-ld May 5, 2023
ad5cda4
fix some CMakeLists.txt CMP0135 errors
cwaldren-ld May 5, 2023
f1c368b
properly disable foxy tests
cwaldren-ld May 5, 2023
e8c7d2d
remove obsolete commented out code
cwaldren-ld May 5, 2023
f74aaac
temporary test to see if I've fixed gtest
cwaldren-ld May 5, 2023
5b6479f
don't be as clever when detecting https
cwaldren-ld May 5, 2023
f4b25e5
simplify EventBatch::Target()
cwaldren-ld May 5, 2023
d806930
make closing SSE socket cleaner
cwaldren-ld May 5, 2023
071cb9e
add back in SSE client close to streaming data source
cwaldren-ld May 5, 2023
8527468
change my-bool-flag in hello-app back to my-boolean-flag
cwaldren-ld May 5, 2023
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
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ project(
LANGUAGES CXX C
)

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
# Affects robustness of timestamp checking on FetchContent dependencies.
cmake_policy(SET CMP0135 NEW)
endif ()

# All projects in this repo should share the same version of 3rd party depends.
# It's the only way to remain sane.
set(CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand All @@ -36,6 +31,10 @@ if (BUILD_TESTING)
endif ()
endif ()
include(FetchContent)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
# Affects robustness of timestamp checking on FetchContent dependencies.
cmake_policy(SET CMP0135 NEW)
endif ()
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
Expand Down
2 changes: 1 addition & 1 deletion apps/hello-cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main() {

client.WaitForReadySync(std::chrono::seconds(30));

auto value = client.BoolVariationDetail("my-bool-flag", false);
auto value = client.BoolVariationDetail("my-boolean-flag", false);
LD_LOG(logger, LogLevel::kInfo) << "Value was: " << *value;
LD_LOG(logger, LogLevel::kInfo) << "Reason was: " << value.Reason();

Expand Down
1 change: 1 addition & 0 deletions apps/sse-contract-tests/src/entity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ bool EntityManager::destroy(std::string const& id) {
return false;
}

it->second.first->close();
it->second.second->stop();

entities_.erase(it);
Expand Down
10 changes: 0 additions & 10 deletions cmake/certify.cmake

This file was deleted.

5 changes: 5 additions & 0 deletions cmake/expected.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.11)

include(FetchContent)

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
# Affects robustness of timestamp checking on FetchContent dependencies.
cmake_policy(SET CMP0135 NEW)
endif ()

FetchContent_Declare(tl-expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG 292eff8bd8ee230a7df1d6a1c00c4ea0eb2f0362
Expand Down
19 changes: 19 additions & 0 deletions cmake/foxy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.11)

include(FetchContent)

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
# Affects robustness of timestamp checking on FetchContent dependencies.
cmake_policy(SET CMP0135 NEW)
endif ()


FetchContent_Declare(foxy
GIT_REPOSITORY https://github.com/launchdarkly/foxy.git
GIT_TAG 7f4ac0495ad2ed9cd0eca5994743d677ac1d2636
)


set(BUILD_TESTING OFF)
FetchContent_MakeAvailable(foxy)
set(BUILD_TESTING ON)
9 changes: 7 additions & 2 deletions cmake/json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ include(FetchContent)

set(JSON_ImplicitConversions OFF)

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
# Affects robustness of timestamp checking on FetchContent dependencies.
cmake_policy(SET CMP0135 NEW)
endif ()

FetchContent_Declare(json
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
)
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
)

FetchContent_MakeAvailable(json)
9 changes: 9 additions & 0 deletions libs/client-sdk/src/data_sources/streaming_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ StreamingDataSource::StreamingDataSource(

auto& http_properties = config.HttpProperties();

// TODO: can the read timeout be shared with *all* http requests? Or should
// it have a default in defaults.hpp? This must be greater than the
// heartbeat interval of the streaming service.
client_builder.read_timeout(std::chrono::minutes(5));

client_builder.write_timeout(http_properties.WriteTimeout());

client_builder.connect_timeout(http_properties.ConnectTimeout());

Copy link
Contributor Author

@cwaldren-ld cwaldren-ld May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO here is because the SSE stream has a heartbeat, so it's not quite the same as a generic HTTP request read timeout.

For instance, it might be appropriate to have a 10 second read timeout on a poll request or whatever, but that could be too short/long for the heartbeat.

I don't know if the heartbeat interval is actually documented anywhere. Will look.

client_builder.header("authorization", config.SdkKey());
for (auto const& header : http_properties.BaseHeaders()) {
client_builder.header(header.first, header.second);
Expand Down
2 changes: 1 addition & 1 deletion libs/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message(STATUS "LaunchDarkly: using Boost v${Boost_VERSION}")


include(${CMAKE_FILES}/expected.cmake)
include(${CMAKE_FILES}/certify.cmake)
include(${CMAKE_FILES}/foxy.cmake)

# Add main SDK sources.
add_subdirectory(src)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ class HttpPropertiesBuilder {
*/
HttpPropertiesBuilder& ReadTimeout(std::chrono::milliseconds read_timeout);

/**
* Set a write timeout. This is how long it takes to perform a write
* operation.
*
* @param read_timeout The write timeout.
* @return A reference to this builder.
*/
HttpPropertiesBuilder& WriteTimeout(
std::chrono::milliseconds write_timeout);

/**
* The time for the first byte to be received during a read. If a byte
* is not received within this time, then the request will be cancelled.
Expand Down Expand Up @@ -115,6 +125,7 @@ class HttpPropertiesBuilder {
private:
std::chrono::milliseconds connect_timeout_;
std::chrono::milliseconds read_timeout_;
std::chrono::milliseconds write_timeout_;
std::chrono::milliseconds response_timeout_;
std::string wrapper_name_;
std::string wrapper_version_;
Expand Down
4 changes: 4 additions & 0 deletions libs/common/include/config/detail/built/http_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ class HttpProperties final {
public:
HttpProperties(std::chrono::milliseconds connect_timeout,
std::chrono::milliseconds read_timeout,
std::chrono::milliseconds write_timeout,
std::chrono::milliseconds response_timeout,
std::string user_agent,
std::map<std::string, std::string> base_headers);

[[nodiscard]] std::chrono::milliseconds ConnectTimeout() const;
[[nodiscard]] std::chrono::milliseconds ReadTimeout() const;
[[nodiscard]] std::chrono::milliseconds WriteTimeout() const;

[[nodiscard]] std::chrono::milliseconds ResponseTimeout() const;
[[nodiscard]] std::string const& UserAgent() const;
[[nodiscard]] std::map<std::string, std::string> const& BaseHeaders() const;

private:
std::chrono::milliseconds connect_timeout_;
std::chrono::milliseconds read_timeout_;
std::chrono::milliseconds write_timeout_;
std::chrono::milliseconds response_timeout_;
std::string user_agent_;
std::map<std::string, std::string> base_headers_;
Expand Down
24 changes: 14 additions & 10 deletions libs/common/include/config/detail/defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ struct Defaults<ClientSDK> {
}

static auto HttpProperties() -> built::HttpProperties {
return {
std::chrono::milliseconds{10000}, std::chrono::milliseconds{10000},
std::chrono::milliseconds{10000}, SdkName() + "/" + SdkVersion(),
std::map<std::string, std::string>()};
return {std::chrono::seconds{10},
std::chrono::seconds{10},
std::chrono::seconds{10},
std::chrono::seconds{10},
SdkName() + "/" + SdkVersion(),
std::map<std::string, std::string>()};
}

static auto StreamingConfig() -> built::StreamingConfig<ClientSDK> {
return {std::chrono::milliseconds{1000}, "/meval"};
return {std::chrono::seconds{1}, "/meval"};
}

static auto DataSourceConfig() -> built::DataSourceConfig<ClientSDK> {
Expand Down Expand Up @@ -91,14 +93,16 @@ struct Defaults<ServerSDK> {
}

static auto HttpProperties() -> built::HttpProperties {
return {
std::chrono::milliseconds{2000}, std::chrono::milliseconds{10000},
std::chrono::milliseconds{10000}, SdkName() + "/" + SdkVersion(),
std::map<std::string, std::string>()};
return {std::chrono::seconds{2},
std::chrono::seconds{10},
std::chrono::seconds{10},
std::chrono::seconds{10},
SdkName() + "/" + SdkVersion(),
std::map<std::string, std::string>()};
}

static auto StreamingConfig() -> built::StreamingConfig<ServerSDK> {
return {std::chrono::milliseconds{1000}};
return {std::chrono::seconds{1}};
}

static auto DataSourceConfig() -> built::DataSourceConfig<ServerSDK> {
Expand Down
Loading