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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ typedef struct _LDClientSDK* LDClientSDK;
LD_EXPORT(LDClientSDK)
LDClientSDK_New(LDClientConfig config, LDContext context);

/**
* Returns the version of the SDK.
* @return String representation of the SDK version.
*/
LD_EXPORT(char const*)
LDClientSDK_Version(void);

/**
* Starts the SDK, initiating a connection to LaunchDarkly if not offline.
*
Expand Down
11 changes: 8 additions & 3 deletions libs/client-sdk/include/launchdarkly/client_side/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,6 @@ class IClient {

class Client : public IClient {
public:
inline static char const* const kVersion =
"0.1.0"; // {x-release-please-version}

Client(Config config, Context context);

Client(Client&&) = delete;
Expand Down Expand Up @@ -315,7 +312,15 @@ class Client : public IClient {

flag_manager::IFlagNotifier& FlagNotifier() override;

/**
* Returns the version of the SDK.
* @return String representing version of the SDK.
*/
[[nodiscard]] static char const* Version();

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

Expand Down
5 changes: 5 additions & 0 deletions libs/client-sdk/src/bindings/c/sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ LDClientSDK_New(LDClientConfig config, LDContext context) {
return FROM_SDK(sdk);
}

LD_EXPORT(char const*)
LDClientSDK_Version(void) {
return Client::Version();
}

LD_EXPORT(bool)
LDClientSDK_Start(LDClientSDK sdk,
unsigned int milliseconds,
Expand Down
4 changes: 4 additions & 0 deletions libs/client-sdk/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ flag_manager::IFlagNotifier& Client::FlagNotifier() {
return client->FlagNotifier();
}

char const* Client::Version() {
return kVersion;
}

} // namespace launchdarkly::client_side
2 changes: 1 addition & 1 deletion libs/client-sdk/src/client_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ClientImpl : public IClient {
ClientImpl(ClientImpl const&) = delete;
ClientImpl& operator=(ClientImpl) = delete;
ClientImpl& operator=(ClientImpl&& other) = delete;

bool Initialized() const override;

using FlagKey = std::string;
Expand Down
4 changes: 4 additions & 0 deletions libs/client-sdk/tests/client_c_bindings_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ TEST(ClientBindings, MinimalInstantiation) {

LDClientSDK sdk = LDClientSDK_New(config, context);

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

LDClientSDK_Free(sdk);
}
4 changes: 4 additions & 0 deletions libs/client-sdk/tests/client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ TEST(ClientTest, ClientConstructedWithMinimalConfigAndContext) {
Context context = ContextBuilder().Kind("cat", "shadow").Build();

Client client(std::move(*config), context);

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

TEST(ClientTest, AllFlagsIsEmpty) {
Expand Down
4 changes: 3 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"libs/client-sdk": {
"initial-version": "0.1.0",
"extra-files": [
"include/launchdarkly/client_side/client.hpp"
"include/launchdarkly/client_side/client.hpp",
"tests/client_c_bindings_test.cpp",
"tests/client_test.cpp"
]
},
"libs/server-sent-events": {
Expand Down