Skip to content

Commit ee7b964

Browse files
committed
Rename many things.
1 parent 55c4ee5 commit ee7b964

17 files changed

+267
-241
lines changed

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ class BarBaz;
3434
DoTheFoo();
3535
Bar();
3636
```
37+
38+
**Methods**
39+
```c++
40+
struct Thing {
41+
uint64_t Size(); // Getter
42+
void DoTheFoo();
43+
};
44+
45+
```
46+
3747
**Constants**
3848
```c++
3949
const int kFooBarBaz = 1;
@@ -58,6 +68,19 @@ In C++:
5868
file_name.cpp
5969
file_name.hpp
6070
```
71+
72+
**Divergence: getters**
73+
74+
```c++
75+
struct Thing {
76+
// Good
77+
uint64_t Size();
78+
79+
//Bad
80+
uint64_t size();
81+
};
82+
```
83+
6184
### C++ Standard
6285

6386
C++17.

libs/client-sdk/include/launchdarkly/client_side/data_source_update_sink.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct ItemDescriptor {
2020
uint64_t version;
2121

2222
/**
23-
* The data item, or nullopt if this is a deleted item placeholder.
23+
* The data item, or nullopt if this is a Deleted item placeholder.
2424
*/
2525
std::optional<EvaluationResult> flag;
2626

@@ -43,8 +43,8 @@ struct ItemDescriptor {
4343
*/
4444
class IDataSourceUpdateSink {
4545
public:
46-
virtual void init(std::unordered_map<std::string, ItemDescriptor> data) = 0;
47-
virtual void upsert(std::string key, ItemDescriptor) = 0;
46+
virtual void Init(std::unordered_map<std::string, ItemDescriptor> data) = 0;
47+
virtual void Upsert(std::string key, ItemDescriptor item) = 0;
4848

4949
// We could add this if we want to support data source status.
5050
// virtual void status(<something>)

libs/client-sdk/include/launchdarkly/client_side/flag_manager/detail/flag_change_event.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ class FlagValueChangeEvent {
1414
* The name of the flag that changed.
1515
* @return The name of the flag.
1616
*/
17-
[[nodiscard]] std::string const& flag_name() const;
17+
[[nodiscard]] std::string const& FlagName() const;
1818

1919
/**
2020
* Get the new value. If there was not an new value, because the flag was
21-
* deleted, then the Value will be of a null type. Check the deleted method
21+
* deleted, then the Value will be of a null type. Check the Deleted method
2222
* to see if a flag was deleted.
2323
*
2424
* @return The new value.
2525
*/
26-
[[nodiscard]] Value const& new_value() const;
26+
[[nodiscard]] Value const& NewValue() const;
2727

2828
/**
2929
* Get the old value. If there was not an old value, for instance a newly
3030
* created flag, then the Value will be of a null type.
3131
*
3232
* @return The new value.
3333
*/
34-
[[nodiscard]] Value const& old_value() const;
34+
[[nodiscard]] Value const& OldValue() const;
3535

3636
/**
37-
* Will be true if the flag was deleted. In which case the new_value will
37+
* Will be true if the flag was deleted. In which case the NewValue will
3838
* be of a null type.
3939
*
4040
* @return True if the flag was deleted.
4141
*/
42-
[[nodiscard]] bool deleted() const;
42+
[[nodiscard]] bool Deleted() const;
4343

4444
/**
4545
* Construct a flag changed event with a new and old value.
4646
*
47-
* This is a change event for a flag that has not been deleted.
47+
* This is a change event for a flag that has not been Deleted.
4848
*
4949
* @param new_value The new value.
5050
* @param old_value The old value.

libs/client-sdk/include/launchdarkly/client_side/flag_manager/detail/flag_manager.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace launchdarkly::client_side::flag_manager::detail {
88

99
class FlagManager {
1010
public:
11-
void init(const std::unordered_map<std::string, ItemDescriptor>& data);
12-
void upsert(const std::string& key, ItemDescriptor item);
11+
void Init(const std::unordered_map<std::string, ItemDescriptor>& data);
12+
void Upsert(const std::string& key, ItemDescriptor item);
1313

1414
/**
1515
* Attempts to get a flag by key from the current flags.
@@ -18,14 +18,14 @@ class FlagManager {
1818
* @return A shared_ptr to the value if present. A null shared_ptr if the
1919
* item is not present.
2020
*/
21-
std::shared_ptr<ItemDescriptor> get(const std::string& flag_key) const;
21+
std::shared_ptr<ItemDescriptor> Get(const std::string& flag_key) const;
2222

2323
/**
2424
* Gets all the current flags.
2525
*
2626
* @return All of the current flags.
2727
*/
28-
std::unordered_map<std::string, std::shared_ptr<ItemDescriptor>> get_all()
28+
std::unordered_map<std::string, std::shared_ptr<ItemDescriptor>> GetAll()
2929
const;
3030

3131
private:

libs/client-sdk/include/launchdarkly/client_side/flag_manager/detail/flag_notifier.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <boost/signals2.hpp>
44

5-
#include "value.hpp"
65
#include "launchdarkly/client_side/flag_manager/detail/flag_change_event.hpp"
6+
#include "value.hpp"
77

88
namespace launchdarkly::client_side::flag_manager::detail {
99

@@ -14,7 +14,7 @@ namespace launchdarkly::client_side::flag_manager::detail {
1414
*/
1515
class IConnection {
1616
public:
17-
virtual void disconnect() = 0;
17+
virtual void Disconnect() = 0;
1818

1919
virtual ~IConnection() = default;
2020
IConnection(IConnection const& item) = delete;
@@ -38,16 +38,17 @@ class IFlagNotifier {
3838
// can use the same instance, and the lifetime is tied to how the consumer
3939
// uses the event.
4040
using ChangeHandler =
41-
std::function<void(std::shared_ptr<FlagValueChangeEvent>)> const&;
41+
std::function<void(std::shared_ptr<FlagValueChangeEvent>)>;
4242

4343
/**
4444
* Listen for changes for the specific flag.
4545
* @param key The flag to listen to changes for.
4646
* @param signal The handler for the changes.
4747
* @return A connection which can be used to stop listening.
4848
*/
49-
virtual std::unique_ptr<IConnection> flag_change(std::string const& key,
50-
ChangeHandler handler) = 0;
49+
virtual std::unique_ptr<IConnection> OnFlagChange(
50+
std::string const& key,
51+
ChangeHandler handler) = 0;
5152

5253
virtual ~IFlagNotifier() = default;
5354
IFlagNotifier(IFlagNotifier const& item) = delete;

libs/client-sdk/include/launchdarkly/client_side/flag_manager/detail/flag_updater.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace launchdarkly::client_side::flag_manager::detail {
1515
class FlagUpdater : public IDataSourceUpdateSink, public IFlagNotifier {
1616
public:
1717
FlagUpdater(FlagManager& flag_manager);
18-
void init(std::unordered_map<std::string, ItemDescriptor> data) override;
19-
void upsert(std::string key, ItemDescriptor item) override;
18+
void Init(std::unordered_map<std::string, ItemDescriptor> data) override;
19+
void Upsert(std::string key, ItemDescriptor item) override;
2020

2121
/**
2222
* Listen for changes for the specific flag.
@@ -25,23 +25,23 @@ class FlagUpdater : public IDataSourceUpdateSink, public IFlagNotifier {
2525
* @return A Connection which can be used to stop listening for changes
2626
* to the flag using this handler.
2727
*/
28-
std::unique_ptr<IConnection> flag_change(
28+
std::unique_ptr<IConnection> OnFlagChange(
2929
std::string const& key,
30-
std::function<void(std::shared_ptr<FlagValueChangeEvent>)> const&
31-
handler) override;
30+
std::function<void(std::shared_ptr<FlagValueChangeEvent>)> handler)
31+
override;
3232

3333
private:
3434
class Connection : public IConnection {
3535
public:
3636
friend class FlagUpdater;
3737
Connection(boost::signals2::connection connection);
38-
void disconnect() override;
38+
void Disconnect() override;
3939

4040
private:
4141
boost::signals2::connection connection_;
4242
};
4343

44-
bool has_listeners() const;
44+
bool HasListeners() const;
4545

4646
FlagManager& flag_manager_;
4747
std::unordered_map<
@@ -54,7 +54,7 @@ class FlagUpdater : public IDataSourceUpdateSink, public IFlagNotifier {
5454
// the mutex, which is more difficult to keep consistent over the code
5555
// lifetime.
5656
mutable std::recursive_mutex signal_mutex_;
57-
void dispatch_event(FlagValueChangeEvent event);
57+
void DispatchEvent(FlagValueChangeEvent event);
5858
};
5959

6060
} // namespace launchdarkly::client_side::flag_manager::detail

libs/client-sdk/src/data_sources/streaming_data_handler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ StreamingDataHandler::MessageStatus StreamingDataHandler::handle_message(
108108
parsed);
109109

110110
if (res.has_value()) {
111-
handler_->init(res.value());
111+
handler_->Init(res.value());
112112
return StreamingDataHandler::MessageStatus::kMessageHandled;
113113
}
114114
LD_LOG(logger_, LogLevel::kError)
@@ -126,7 +126,7 @@ StreamingDataHandler::MessageStatus StreamingDataHandler::handle_message(
126126
auto res = boost::json::value_to<
127127
tl::expected<StreamingDataHandler::PatchData, JsonError>>(parsed);
128128
if (res.has_value()) {
129-
handler_->upsert(
129+
handler_->Upsert(
130130
res.value().key,
131131
launchdarkly::client_side::ItemDescriptor(res.value().flag));
132132
return StreamingDataHandler::MessageStatus::kMessageHandled;
@@ -147,7 +147,7 @@ StreamingDataHandler::MessageStatus StreamingDataHandler::handle_message(
147147
tl::expected<StreamingDataHandler::DeleteData, JsonError>>(
148148
boost::json::parse(event.data()));
149149
if (res.has_value()) {
150-
handler_->upsert(res.value().key,
150+
handler_->Upsert(res.value().key,
151151
ItemDescriptor(res.value().version));
152152
return StreamingDataHandler::MessageStatus::kMessageHandled;
153153
}

libs/client-sdk/src/flag_manager/flag_change_event.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
namespace launchdarkly::client_side::flag_manager::detail {
44

5-
std::string const& FlagValueChangeEvent::flag_name() const {
5+
std::string const& FlagValueChangeEvent::FlagName() const {
66
return flag_name_;
77
}
88

9-
Value const& FlagValueChangeEvent::new_value() const {
9+
Value const& FlagValueChangeEvent::NewValue() const {
1010
return new_value_;
1111
}
1212

13-
Value const& FlagValueChangeEvent::old_value() const {
13+
Value const& FlagValueChangeEvent::OldValue() const {
1414
return old_value_;
1515
}
1616

17-
bool FlagValueChangeEvent::deleted() const {
17+
bool FlagValueChangeEvent::Deleted() const {
1818
return deleted_;
1919
}
2020

libs/client-sdk/src/flag_manager/flag_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace launchdarkly::client_side::flag_manager::detail {
77
// accessed, and which it is being used init is called, then we want the
88
// flag being processed to be valid.
99

10-
void FlagManager::init(
10+
void FlagManager::Init(
1111
std::unordered_map<std::string, ItemDescriptor> const& data) {
1212
std::lock_guard lock{data_mutex_};
1313

@@ -18,13 +18,13 @@ void FlagManager::init(
1818
}
1919
}
2020

21-
void FlagManager::upsert(std::string const& key, ItemDescriptor item) {
21+
void FlagManager::Upsert(std::string const& key, ItemDescriptor item) {
2222
std::lock_guard lock{data_mutex_};
2323

2424
data_[key] = std::make_shared<ItemDescriptor>(std::move(item));
2525
}
2626

27-
std::shared_ptr<ItemDescriptor> FlagManager::get(
27+
std::shared_ptr<ItemDescriptor> FlagManager::Get(
2828
std::string const& flag_key) const {
2929
std::lock_guard lock{data_mutex_};
3030

@@ -36,7 +36,7 @@ std::shared_ptr<ItemDescriptor> FlagManager::get(
3636
}
3737

3838
std::unordered_map<std::string, std::shared_ptr<ItemDescriptor>>
39-
FlagManager::get_all() const {
39+
FlagManager::GetAll() const {
4040
std::lock_guard lock{data_mutex_};
4141

4242
// Returns a copy of the map. (The descriptors are pointers and not shared).

0 commit comments

Comments
 (0)