Skip to content

Commit a3dfc38

Browse files
committed
fix: inline Membership methods so dynamodb/redis dylibs can link
1 parent 2d92bc7 commit a3dfc38

3 files changed

Lines changed: 27 additions & 39 deletions

File tree

libs/server-sdk/include/launchdarkly/server_side/integrations/big_segments/big_segment_store_types.hpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <optional>
55
#include <string>
66
#include <unordered_map>
7+
#include <utility>
78
#include <vector>
89

910
namespace launchdarkly::server_side::integrations {
@@ -21,6 +22,10 @@ namespace launchdarkly::server_side::integrations {
2122
* A "segment ref" is the string `<segmentKey>.g<generation>`; the SDK
2223
* constructs that string when evaluating a flag and passes it to @ref
2324
* CheckMembership.
25+
*
26+
* Implemented inline because integration libraries link against the
27+
* server-sdk shared library, which only exports the C API — out-of-line
28+
* symbols defined here would not be visible to consumers.
2429
*/
2530
class Membership {
2631
public:
@@ -29,7 +34,7 @@ class Membership {
2934
* context is included in / excluded from.
3035
*
3136
* If the same segment ref appears in both lists, inclusion wins, matching
32-
* the LaunchDarkly Big Segments spec (and the Java/Go SDK behavior).
37+
* the LaunchDarkly Big Segments spec.
3338
*
3439
* @param included_segment_refs Segment refs the context is explicitly
3540
* included in.
@@ -38,7 +43,18 @@ class Membership {
3843
*/
3944
static Membership FromSegmentRefs(
4045
std::vector<std::string> const& included_segment_refs,
41-
std::vector<std::string> const& excluded_segment_refs);
46+
std::vector<std::string> const& excluded_segment_refs) {
47+
std::unordered_map<std::string, bool> entries;
48+
// Excluded first so any overlap is overwritten by the included pass;
49+
// inclusion wins per the spec.
50+
for (auto const& ref : excluded_segment_refs) {
51+
entries[ref] = false;
52+
}
53+
for (auto const& ref : included_segment_refs) {
54+
entries[ref] = true;
55+
}
56+
return Membership(std::move(entries));
57+
}
4258

4359
/**
4460
* @brief Returns the membership state for a single segment ref.
@@ -48,10 +64,17 @@ class Membership {
4864
* `std::nullopt` if the segment ref has no entry in this membership.
4965
*/
5066
[[nodiscard]] std::optional<bool> CheckMembership(
51-
std::string const& segment_ref) const;
67+
std::string const& segment_ref) const {
68+
auto const it = entries_.find(segment_ref);
69+
if (it == entries_.end()) {
70+
return std::nullopt;
71+
}
72+
return it->second;
73+
}
5274

5375
private:
54-
explicit Membership(std::unordered_map<std::string, bool> entries);
76+
explicit Membership(std::unordered_map<std::string, bool> entries)
77+
: entries_(std::move(entries)) {}
5578

5679
// segment-ref → true (included) / false (excluded). Inclusion is the
5780
// stored value when a ref appears in both lists at construction time.

libs/server-sdk/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ target_sources(${LIBNAME}
3232
all_flags_state/json_all_flags_state.cpp
3333
all_flags_state/all_flags_state_builder.cpp
3434
integrations/data_reader/kinds.cpp
35-
integrations/big_segments/big_segment_store_types.cpp
3635
prereq_event_recorder/prereq_event_recorder.cpp
3736
prereq_event_recorder/prereq_event_recorder.hpp
3837
data_components/change_notifier/change_notifier.hpp

libs/server-sdk/src/integrations/big_segments/big_segment_store_types.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)