diff --git a/.clang-format b/.clang-format index 50efaa6a0..c45278f7c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,62 +1,41 @@ ---- -AccessModifierOffset: -2 +--- +AccessModifierOffset: '-2' AlignAfterOpenBracket: Align AlignEscapedNewlines: Right -AlignOperands: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: 'false' AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: true -BinPackParameters: true -BreakBeforeBinaryOperators: All +AlwaysBreakTemplateDeclarations: 'Yes' +BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Attach -BreakBeforeTernaryOperators: true +BreakBeforeTernaryOperators: 'true' BreakConstructorInitializers: BeforeColon BreakInheritanceList: BeforeColon -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 2 -ContinuationIndentWidth: 2 -Cpp11BracedListStyle: true -FixNamespaceComments: true +ColumnLimit: '80' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' +ConstructorInitializerIndentWidth: '2' +ContinuationIndentWidth: '2' +Cpp11BracedListStyle: 'true' +FixNamespaceComments: 'true' IncludeBlocks: Preserve -IndentCaseLabels: true +IndentCaseLabels: 'true' IndentPPDirectives: AfterHash -IndentWidth: 2 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false +IndentWidth: '2' +KeepEmptyLinesAtTheStartOfBlocks: 'false' Language: Cpp -MacroBlockBegin: "^BEGIN_STATE$|CAF_BEGIN_TYPE_ID_BLOCK" -MacroBlockEnd: "^END_STATE$|CAF_END_TYPE_ID_BLOCK" -MaxEmptyLinesToKeep: 1 +MacroBlockBegin: ^BEGIN_STATE$|CAF_BEGIN_TYPE_ID_BLOCK +MacroBlockEnd: ^END_STATE$|CAF_END_TYPE_ID_BLOCK +MaxEmptyLinesToKeep: '1' NamespaceIndentation: None -PenaltyBreakAssignment: 25 -PenaltyBreakBeforeFirstCallParameter: 50 -PenaltyReturnTypeOnItsOwnLine: 25 +PenaltyBreakAssignment: '21' +PenaltyBreakBeforeFirstCallParameter: '60' +PenaltyReturnTypeOnItsOwnLine: '50' PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: true -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true +SpaceAfterCStyleCast: 'true' SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false +SpacesBeforeTrailingComments: '1' Standard: Cpp11 UseTab: Never + ... diff --git a/bindings/python/_broker.cpp b/bindings/python/_broker.cpp index 3742a12a5..7bcdec25c 100644 --- a/bindings/python/_broker.cpp +++ b/bindings/python/_broker.cpp @@ -96,14 +96,14 @@ PYBIND11_MODULE(_broker, m) { init_store(m); auto version = m.def_submodule("Version", "Version constants"); - version.attr("MAJOR") - = py::cast(new broker::version::type{broker::version::major}); - version.attr("MINOR") - = py::cast(new broker::version::type{broker::version::minor}); - version.attr("PATCH") - = py::cast(new broker::version::type{broker::version::patch}); - version.attr("PROTOCOL") - = py::cast(new broker::version::type{broker::version::protocol}); + version.attr("MAJOR") = + py::cast(new broker::version::type{broker::version::major}); + version.attr("MINOR") = + py::cast(new broker::version::type{broker::version::minor}); + version.attr("PATCH") = + py::cast(new broker::version::type{broker::version::patch}); + version.attr("PROTOCOL") = + py::cast(new broker::version::type{broker::version::protocol}); version.def("compatible", &broker::version::compatible, "Checks whether two Broker protocol versions are compatible"); @@ -333,8 +333,7 @@ PYBIND11_MODULE(_broker, m) { // created one in, which is unfortunate. struct Configuration { Configuration(){}; - Configuration(broker::broker_options opts) : options(std::move(opts)) { - } + Configuration(broker::broker_options opts) : options(std::move(opts)) {} broker::broker_options options = {}; std::string openssl_cafile; std::string openssl_capath; diff --git a/bindings/python/data.cpp b/bindings/python/data.cpp index 145a9cbbd..1854c02ca 100644 --- a/bindings/python/data.cpp +++ b/bindings/python/data.cpp @@ -25,8 +25,7 @@ using namespace pybind11::literals; // A thin wrapper around the 'count' type, because Python has no notion of // unsigned integers. struct count_type { - count_type(broker::count c) : value{c} { - } + count_type(broker::count c) : value{c} {} bool operator==(const count_type& other) const { return value == other.value; } diff --git a/bindings/python/set_bind.h b/bindings/python/set_bind.h index 2d7bbe3b2..8eab03ec0 100644 --- a/bindings/python/set_bind.h +++ b/bindings/python/set_bind.h @@ -14,23 +14,19 @@ PYBIND11_NAMESPACE_BEGIN(detail) * std::pair for maps) */ template struct is_comparable::is_set>> { - static constexpr const bool value - = is_comparable::value; + static constexpr const bool value = + is_comparable::value; }; /* Fallback functions */ template -void set_if_copy_constructible(const Args&...) { -} +void set_if_copy_constructible(const Args&...) {} template -void set_if_equal_operator(const Args&...) { -} +void set_if_equal_operator(const Args&...) {} template -void set_if_insertion_operator(const Args&...) { -} +void set_if_insertion_operator(const Args&...) {} template -void set_modifiers(const Args&...) { -} +void set_modifiers(const Args&...) {} template void set_if_copy_constructible( @@ -118,8 +114,8 @@ PYBIND11_NAMESPACE_END(detail) // template , typename... Args> -class_ -bind_set(module& m, std::string const& name, Args&&... args) { +class_ bind_set(module& m, std::string const& name, + Args&&... args) { using Class_ = class_; Class_ cl(m, name.c_str(), std::forward(args)...); diff --git a/doc/_examples/comm.cc b/doc/_examples/comm.cc index 43604c06b..1021486d0 100644 --- a/doc/_examples/comm.cc +++ b/doc/_examples/comm.cc @@ -4,8 +4,7 @@ using namespace broker; -int main() { -} +int main() {} void f1() { // --get-start diff --git a/doc/_examples/stores.cc b/doc/_examples/stores.cc index 2e12dced8..dac8d880f 100644 --- a/doc/_examples/stores.cc +++ b/doc/_examples/stores.cc @@ -5,8 +5,7 @@ using namespace broker; -int main() { -} +int main() {} void f1() { // --attach-master-start diff --git a/include/broker/alm/multipath.hh b/include/broker/alm/multipath.hh index 34c87221d..a669753c1 100644 --- a/include/broker/alm/multipath.hh +++ b/include/broker/alm/multipath.hh @@ -131,8 +131,8 @@ public: private: template - std::pair - emplace_impl(const endpoint_id& id, MakeNewNode make_new_node); + std::pair emplace_impl(const endpoint_id& id, + MakeNewNode make_new_node); void shallow_delete() noexcept; diff --git a/include/broker/detail/abstract_backend.hh b/include/broker/detail/abstract_backend.hh index 555642a56..c60546981 100644 --- a/include/broker/detail/abstract_backend.hh +++ b/include/broker/detail/abstract_backend.hh @@ -26,8 +26,8 @@ public: /// @param value The value associated with *key*. /// @param expiry An optional expiration time for the entry. /// @returns `nil` on success. - virtual expected - put(const data& key, data value, std::optional expiry = {}) = 0; + virtual expected put(const data& key, data value, + std::optional expiry = {}) = 0; /// Adds one value to another value. /// @param key The key associated with the existing value to add to. diff --git a/include/broker/detail/monotonic_buffer_resource.hh b/include/broker/detail/monotonic_buffer_resource.hh index ebfefa321..5a50f41be 100644 --- a/include/broker/detail/monotonic_buffer_resource.hh +++ b/include/broker/detail/monotonic_buffer_resource.hh @@ -16,8 +16,8 @@ public: monotonic_buffer_resource(const monotonic_buffer_resource&) = delete; - monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) - = delete; + monotonic_buffer_resource& + operator=(const monotonic_buffer_resource&) = delete; ~monotonic_buffer_resource() noexcept { destroy(); diff --git a/include/broker/detail/native_socket.hh b/include/broker/detail/native_socket.hh index 0f8bed72d..cf6263eeb 100644 --- a/include/broker/detail/native_socket.hh +++ b/include/broker/detail/native_socket.hh @@ -11,8 +11,8 @@ namespace broker::detail { using native_socket = size_t; -constexpr native_socket invalid_native_socket - = std::numeric_limits::max(); +constexpr native_socket invalid_native_socket = + std::numeric_limits::max(); #else // BROKER_WINDOWS diff --git a/include/broker/detail/radix_tree.hh b/include/broker/detail/radix_tree.hh index 04a67855b..fc3805a40 100644 --- a/include/broker/detail/radix_tree.hh +++ b/include/broker/detail/radix_tree.hh @@ -113,10 +113,8 @@ public: struct node_visit { node* n; uint16_t idx; - node_visit(node* arg_n) : n(arg_n), idx(0) { - } - node_visit(node* arg_n, uint16_t arg_i) : n(arg_n), idx(arg_i) { - } + node_visit(node* arg_n) : n(arg_n), idx(0) {} + node_visit(node* arg_n, uint16_t arg_i) : n(arg_n), idx(arg_i) {} }; node* root; @@ -128,8 +126,7 @@ public: /** * Default construct an empty container. */ - explicit radix_tree() : num_entries(0), root(nullptr) { - } + explicit radix_tree() : num_entries(0), root(nullptr) {} /** * Destructor. @@ -279,15 +276,13 @@ private: node256, }; - node(tag t) : type(t) { - } + node(tag t) : type(t) {} node(tag t, const node& other) : type(t), num_children(other.num_children), partial_len(other.partial_len), - partial(other.partial) { - } + partial(other.partial) {} tag type; uint8_t num_children = 0; @@ -304,8 +299,7 @@ private: std::array children = {}; node4() = default; - node4(const node& other) : n(node::tag::node4, other) { - } + node4(const node& other) : n(node::tag::node4, other) {} void add_child(node** ref, unsigned char c, node* child); void rem_child(node** ref, node** child); @@ -320,8 +314,7 @@ private: std::array children = {}; node16() = default; - node16(const node& other) : n(node::tag::node16, other) { - } + node16(const node& other) : n(node::tag::node16, other) {} void add_child(node** ref, unsigned char c, node* child); void rem_child(node** ref, node** child); @@ -337,8 +330,7 @@ private: std::array children = {}; node48() = default; - node48(const node& other) : n(node::tag::node48, other) { - } + node48(const node& other) : n(node::tag::node48, other) {} void add_child(node** ref, unsigned char c, node* child); void rem_child(node** ref, unsigned char c); @@ -352,8 +344,7 @@ private: std::array children = {}; node256() = default; - node256(const node& other) : n(node::tag::node256, other) { - } + node256(const node& other) : n(node::tag::node256, other) {} void add_child(node** ref, unsigned char c, node* child); void rem_child(node** ref, unsigned char c); @@ -366,8 +357,7 @@ private: typename node::tag type; value_type kv; - leaf(value_type arg_kv) : type(node::tag::leaf), kv(std::move(arg_kv)) { - } + leaf(value_type arg_kv) : type(node::tag::leaf), kv(std::move(arg_kv)) {} const key_type& key() const { return kv.first; @@ -699,8 +689,8 @@ radix_tree::find_child(node* n, unsigned char c) { } template -size_t -radix_tree::prefix_shared(node* n, const key_type& key, int depth) { +size_t radix_tree::prefix_shared(node* n, const key_type& key, + int depth) { auto key_data = as_key_data(key); // Null-terminator is part of the key. auto max_cmp = std::min(std::min(N, static_cast(n->partial_len)), @@ -715,8 +705,8 @@ radix_tree::prefix_shared(node* n, const key_type& key, int depth) { } template -size_t -radix_tree::prefix_mismatch(node* n, const key_type& key, int depth) { +size_t radix_tree::prefix_mismatch(node* n, const key_type& key, + int depth) { auto key_data = as_key_data(key); // Null-terminator is part of the key. auto max_cmp = std::min(std::min(N, static_cast(n->partial_len)), @@ -1255,8 +1245,7 @@ void radix_tree::node256::rem_child(node** ref, unsigned char c) { template radix_tree::iterator::iterator(node* arg_root, node* starting_point) - : root(arg_root), node_ptr(starting_point), ready_to_iterate(false) { -} + : root(arg_root), node_ptr(starting_point), ready_to_iterate(false) {} template typename radix_tree::iterator::reference diff --git a/include/broker/detail/subscription.hh b/include/broker/detail/subscription.hh index 010e92ac7..8f56e6203 100644 --- a/include/broker/detail/subscription.hh +++ b/include/broker/detail/subscription.hh @@ -26,8 +26,7 @@ public: /// Construct from given actor and topic set. subscriber(caf::actor a, topic_set ts) - : who(std::move(a)), subscriptions(std::move(ts)) { - } + : who(std::move(a)), subscriptions(std::move(ts)) {} caf::actor who = caf::invalid_actor; topic_set subscriptions; diff --git a/include/broker/detail/type_traits.hh b/include/broker/detail/type_traits.hh index daedec288..d196c816a 100644 --- a/include/broker/detail/type_traits.hh +++ b/include/broker/detail/type_traits.hh @@ -36,8 +36,8 @@ struct are_same { template struct are_same { - static constexpr bool value - = std::is_same_v && are_same::value; + static constexpr bool value = + std::is_same_v && are_same::value; }; template @@ -65,8 +65,8 @@ auto has_apply_operator_test(U*) -> decltype(&U::operator(), std::true_type()); auto has_apply_operator_test(...) -> std::false_type; template -inline constexpr bool has_apply_operator - = decltype(has_apply_operator_test(std::declval()))::value; +inline constexpr bool has_apply_operator = + decltype(has_apply_operator_test(std::declval()))::value; template struct normalized_signature; diff --git a/include/broker/endpoint.hh b/include/broker/endpoint.hh index 96920d097..cfbb610c8 100644 --- a/include/broker/endpoint.hh +++ b/include/broker/endpoint.hh @@ -309,8 +309,8 @@ public: /// incoming messages. The worker will run in the background, but `init` is /// guaranteed to be called before the function returns. template - worker - subscribe(filter_type filter, Init init, OnNext on_next, Cleanup cleanup) { + worker subscribe(filter_type filter, Init init, OnNext on_next, + Cleanup cleanup) { return do_subscribe(std::move(filter), detail::make_sink_driver(std::move(init), std::move(on_next), diff --git a/include/broker/error.hh b/include/broker/error.hh index 0ef63fbcd..a6d529181 100644 --- a/include/broker/error.hh +++ b/include/broker/error.hh @@ -207,9 +207,9 @@ error make_error(ec code, endpoint_info info, std::string description); /// in its context. /// @relates ec template -constexpr bool ec_has_network_info_v - = E == ec::peer_invalid || E == ec::peer_unavailable - || E == ec::peer_disconnect_during_handshake; +constexpr bool ec_has_network_info_v = + E == ec::peer_invalid || E == ec::peer_unavailable + || E == ec::peer_disconnect_during_handshake; /// @relates ec template diff --git a/include/broker/expected.hh b/include/broker/expected.hh index 763e5c68c..b82951478 100644 --- a/include/broker/expected.hh +++ b/include/broker/expected.hh @@ -29,14 +29,14 @@ public: // -- static member variables ------------------------------------------------ /// Stores whether move construct and move assign never throw. - static constexpr bool nothrow_move - = std::is_nothrow_move_constructible_v // - && std::is_nothrow_move_assignable_v; + static constexpr bool nothrow_move = + std::is_nothrow_move_constructible_v // + && std::is_nothrow_move_assignable_v; /// Stores whether copy construct and copy assign never throw. - static constexpr bool nothrow_copy - = std::is_nothrow_copy_constructible_v // - && std::is_nothrow_copy_assignable_v; + static constexpr bool nothrow_copy = + std::is_nothrow_copy_constructible_v // + && std::is_nothrow_copy_assignable_v; // -- constructors, destructors, and assignment operators -------------------- diff --git a/include/broker/fwd.hh b/include/broker/fwd.hh index c84fbe761..f27a05ed8 100644 --- a/include/broker/fwd.hh +++ b/include/broker/fwd.hh @@ -94,12 +94,12 @@ using timespan = std::chrono::duration; using timestamp = std::chrono::time_point; using vector = std::vector; -using internal_command_variant - = std::variant; +using internal_command_variant = + std::variant; // -- arithmetic type aliases -------------------------------------------------- @@ -136,8 +136,8 @@ using routing_table = std::unordered_map; namespace broker { -using packed_message - = cow_tuple>; +using packed_message = + cow_tuple>; using command_message = cow_tuple; using data_message = cow_tuple; using node_message = cow_tuple; diff --git a/include/broker/internal/channel.hh b/include/broker/internal/channel.hh index c1ed42329..2ef006301 100644 --- a/include/broker/internal/channel.hh +++ b/include/broker/internal/channel.hh @@ -114,8 +114,8 @@ public: // -- implementation of the producer ----------------------------------------- /// Messages sent by the producer. - using producer_message - = std::variant; + using producer_message = + std::variant; struct default_producer_base {}; diff --git a/include/broker/internal/clone_actor.hh b/include/broker/internal/clone_actor.hh index b9f8a331a..1eb52364c 100644 --- a/include/broker/internal/clone_actor.hh +++ b/include/broker/internal/clone_actor.hh @@ -179,9 +179,10 @@ public: using clone_actor_type = caf::stateful_actor; -caf::behavior -clone_actor(clone_actor_type* self, endpoint_id this_endpoint, caf::actor core, - std::string id, double resync_interval, double stale_interval, - double mutation_buffer_interval, endpoint::clock* ep_clock); +caf::behavior clone_actor(clone_actor_type* self, endpoint_id this_endpoint, + caf::actor core, std::string id, + double resync_interval, double stale_interval, + double mutation_buffer_interval, + endpoint::clock* ep_clock); } // namespace broker::internal diff --git a/include/broker/internal/connector.hh b/include/broker/internal/connector.hh index 719ce1e49..d3f2fc9cb 100644 --- a/include/broker/internal/connector.hh +++ b/include/broker/internal/connector.hh @@ -44,16 +44,14 @@ public: /// Signals that a remote node has connected to this peer. virtual void on_connection(connector_event_id event_id, endpoint_id peer, network_info addr, filter_type filter, - pending_connection_ptr ptr) - = 0; + pending_connection_ptr ptr) = 0; virtual void on_redundant_connection(connector_event_id event_id, - endpoint_id peer, network_info addr) - = 0; + endpoint_id peer, + network_info addr) = 0; - virtual void - on_drop(connector_event_id event_id, std::optional peer) - = 0; + virtual void on_drop(connector_event_id event_id, + std::optional peer) = 0; virtual void on_listen(connector_event_id event_id, uint16_t port) = 0; diff --git a/include/broker/internal/core_actor.hh b/include/broker/internal/core_actor.hh index 63ed5048f..507117da6 100644 --- a/include/broker/internal/core_actor.hh +++ b/include/broker/internal/core_actor.hh @@ -216,9 +216,10 @@ public: backend_options opts); /// Attaches a clone for given store to this peer. - caf::result - attach_clone(const std::string& name, double resync_interval, - double stale_interval, double mutation_buffer_interval); + caf::result attach_clone(const std::string& name, + double resync_interval, + double stale_interval, + double mutation_buffer_interval); /// Terminates all masters and clones by sending exit messages to the /// corresponding actors. @@ -302,8 +303,8 @@ public: /// Synchronizes information about the current status of a peering with the /// connector. - detail::shared_peer_status_map_ptr peer_statuses - = std::make_shared(); + detail::shared_peer_status_map_ptr peer_statuses = + std::make_shared(); /// Buffer for serializing messages. Having this as a member allows us to /// re-use the same heap-allocated buffer instead of always allocating fresh diff --git a/include/broker/internal/generator_file_reader.hh b/include/broker/internal/generator_file_reader.hh index 59a9d4f8e..67548ffbd 100644 --- a/include/broker/internal/generator_file_reader.hh +++ b/include/broker/internal/generator_file_reader.hh @@ -30,8 +30,8 @@ public: using file_handle_type = detail::native_socket; #endif - using read_raw_callback - = std::function)>; + using read_raw_callback = + std::function)>; generator_file_reader(file_handle_type fd, mapper_handle mapper, mapped_pointer addr, size_t file_size); diff --git a/include/broker/internal/metric_exporter.hh b/include/broker/internal/metric_exporter.hh index 54d659da8..a2fa479ba 100644 --- a/include/broker/internal/metric_exporter.hh +++ b/include/broker/internal/metric_exporter.hh @@ -184,7 +184,7 @@ public: static inline const char* name = "broker.exporter"; }; -using metric_exporter_actor - = caf::stateful_actor>; +using metric_exporter_actor = + caf::stateful_actor>; } // namespace broker::internal diff --git a/include/broker/internal/pending_connection.hh b/include/broker/internal/pending_connection.hh index 05f88d8f8..5e1db7a23 100644 --- a/include/broker/internal/pending_connection.hh +++ b/include/broker/internal/pending_connection.hh @@ -21,8 +21,7 @@ public: /// @param push The resource where the connection pushes data to. virtual caf::error run(caf::actor_system& sys, caf::async::consumer_resource pull, - caf::async::producer_resource push) - = 0; + caf::async::producer_resource push) = 0; }; /// @relates pending_connection diff --git a/include/broker/internal/web_socket.hh b/include/broker/internal/web_socket.hh index f05cf7c9d..dbf71be52 100644 --- a/include/broker/internal/web_socket.hh +++ b/include/broker/internal/web_socket.hh @@ -15,8 +15,8 @@ using push_t = caf::async::producer_resource; using connect_event_t = std::pair; -using on_connect_t - = std::function; +using on_connect_t = + std::function; expected launch(caf::actor_system& sys, openssl_options_ptr ssl_cfg, std::string addr, uint16_t port, bool reuse_addr, diff --git a/include/broker/internal/wire_format.hh b/include/broker/internal/wire_format.hh index f3aab6442..79bd67846 100644 --- a/include/broker/internal/wire_format.hh +++ b/include/broker/internal/wire_format.hh @@ -262,10 +262,10 @@ struct var_msg_error { }; /// Convenience type for handling phase 1 and phase 2 messages. -using var_msg - = std::variant; +using var_msg = + std::variant; /// @relates var_msg std::string stringify(const var_msg& msg); diff --git a/include/broker/internal_command.hh b/include/broker/internal_command.hh index 7af86354b..9fdef73ee 100644 --- a/include/broker/internal_command.hh +++ b/include/broker/internal_command.hh @@ -294,12 +294,12 @@ bool inspect(Inspector& f, retransmit_failed_command& x) { // -- variant setup ------------------------------------------------------------ -using internal_command_variant - = std::variant; +using internal_command_variant = + std::variant; class internal_command { public: diff --git a/include/broker/message.hh b/include/broker/message.hh index 84a4fe6ea..95228bc5c 100644 --- a/include/broker/message.hh +++ b/include/broker/message.hh @@ -70,8 +70,8 @@ bool inspect(Inspector& f, packed_message_type& x) { } /// A Broker-internal message with a payload received from the ALM layer. -using packed_message - = cow_tuple>; +using packed_message = + cow_tuple>; /// @relates packed_message inline packed_message make_packed_message(packed_message_type type, diff --git a/include/broker/span.hh b/include/broker/span.hh index 3498f9e03..ceb440ac8 100644 --- a/include/broker/span.hh +++ b/include/broker/span.hh @@ -47,33 +47,27 @@ public: // -- constructors, destructors, and assignment operators ------------------ - constexpr span() noexcept : memory_block(nullptr), num_elements(0) { - } + constexpr span() noexcept : memory_block(nullptr), num_elements(0) {} constexpr span(pointer ptr, size_t size) - : memory_block(ptr), num_elements(size) { - } + : memory_block(ptr), num_elements(size) {} constexpr span(pointer first, pointer last) - : memory_block(first), num_elements(static_cast(last - first)) { - } + : memory_block(first), num_elements(static_cast(last - first)) {} template constexpr span(element_type (&arr)[Size]) noexcept - : memory_block(arr), num_elements(Size) { - } + : memory_block(arr), num_elements(Size) {} template >> span(Container& xs) noexcept - : memory_block(xs.data()), num_elements(xs.size()) { - } + : memory_block(xs.data()), num_elements(xs.size()) {} template >> span(const Container& xs) noexcept - : memory_block(xs.data()), num_elements(xs.size()) { - } + : memory_block(xs.data()), num_elements(xs.size()) {} constexpr span(const span&) noexcept = default; diff --git a/include/broker/status.hh b/include/broker/status.hh index 1c78864f0..71029f89c 100644 --- a/include/broker/status.hh +++ b/include/broker/status.hh @@ -82,8 +82,8 @@ constexpr bool sc_has_endpoint_info_v = S != sc::unspecified; /// in its context. /// @relates sc template -constexpr bool sc_has_network_info_v - = S == sc::peer_added || S == sc::peer_removed || S == sc::peer_lost; +constexpr bool sc_has_network_info_v = + S == sc::peer_added || S == sc::peer_removed || S == sc::peer_lost; template <> struct can_convert_predicate { diff --git a/include/broker/telemetry/fwd.hh b/include/broker/telemetry/fwd.hh index ed1d285b4..99fffb329 100644 --- a/include/broker/telemetry/fwd.hh +++ b/include/broker/telemetry/fwd.hh @@ -232,15 +232,17 @@ dbl_counter_fam(metric_registry_impl*, std::string_view pre, std::string_view name, span labels, std::string_view helptext, std::string_view unit, bool is_sum); -int_gauge_family_hdl* -int_gauge_fam(metric_registry_impl*, std::string_view pre, - std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum); - -dbl_gauge_family_hdl* -dbl_gauge_fam(metric_registry_impl*, std::string_view pre, - std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum); +int_gauge_family_hdl* int_gauge_fam(metric_registry_impl*, std::string_view pre, + std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, bool is_sum); + +dbl_gauge_family_hdl* dbl_gauge_fam(metric_registry_impl*, std::string_view pre, + std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, bool is_sum); int_histogram_family_hdl* int_histogram_fam(metric_registry_impl*, std::string_view pre, diff --git a/include/broker/telemetry/metric_registry_impl.hh b/include/broker/telemetry/metric_registry_impl.hh index de6319d58..59e720f63 100644 --- a/include/broker/telemetry/metric_registry_impl.hh +++ b/include/broker/telemetry/metric_registry_impl.hh @@ -53,40 +53,36 @@ public: virtual int_counter_family_hdl* int_counter_fam(std::string_view pre, std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum) - = 0; + std::string_view helptext, std::string_view unit, + bool is_sum) = 0; virtual dbl_counter_family_hdl* dbl_counter_fam(std::string_view pre, std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum) - = 0; + std::string_view helptext, std::string_view unit, + bool is_sum) = 0; virtual int_gauge_family_hdl* int_gauge_fam(std::string_view pre, std::string_view name, span labels, std::string_view helptext, - std::string_view unit, bool is_sum) - = 0; + std::string_view unit, bool is_sum) = 0; virtual dbl_gauge_family_hdl* dbl_gauge_fam(std::string_view pre, std::string_view name, span labels, std::string_view helptext, - std::string_view unit, bool is_sum) - = 0; + std::string_view unit, bool is_sum) = 0; virtual int_histogram_family_hdl* int_histogram_fam(std::string_view pre, std::string_view name, span labels, span ubounds, std::string_view helptext, - std::string_view unit, bool is_sum) - = 0; + std::string_view unit, bool is_sum) = 0; virtual dbl_histogram_family_hdl* dbl_histogram_fam(std::string_view pre, std::string_view name, span labels, span ubounds, std::string_view helptext, - std::string_view unit, bool is_sum) - = 0; + std::string_view unit, bool is_sum) = 0; // Collect metrics. virtual void collect(metrics_collector& collector) = 0; diff --git a/include/broker/topic.hh b/include/broker/topic.hh index 959602448..bd26dfd53 100644 --- a/include/broker/topic.hh +++ b/include/broker/topic.hh @@ -28,8 +28,8 @@ public: static constexpr std::string_view statuses_str = "<$>/local/data/statuses"; - static constexpr std::string_view store_events_str - = "<$>/local/data/store-events"; + static constexpr std::string_view store_events_str = + "<$>/local/data/store-events"; static topic master_suffix(); diff --git a/include/broker/zeek.hh b/include/broker/zeek.hh index 35993c0c2..ff466921f 100644 --- a/include/broker/zeek.hh +++ b/include/broker/zeek.hh @@ -82,11 +82,9 @@ public: protected: Message(Type type, vector content) - : data_(vector{ProtocolVersion, count(type), std::move(content)}) { - } + : data_(vector{ProtocolVersion, count(type), std::move(content)}) {} - Message(data msg) : data_(std::move(msg)) { - } + Message(data msg) : data_(std::move(msg)) {} data data_; }; @@ -95,11 +93,9 @@ protected: class Event : public Message { public: Event(std::string name, vector args) - : Message(Message::Type::Event, {std::move(name), std::move(args)}) { - } + : Message(Message::Type::Event, {std::move(name), std::move(args)}) {} - Event(data msg) : Message(std::move(msg)) { - } + Event(data msg) : Message(std::move(msg)) {} const std::string& name() const { return get(get(as_vector()[2])[0]); @@ -148,11 +144,9 @@ public: /// A batch of other messages. class Batch : public Message { public: - Batch(vector msgs) : Message(Message::Type::Batch, std::move(msgs)) { - } + Batch(vector msgs) : Message(Message::Type::Batch, std::move(msgs)) {} - Batch(data msg) : Message(std::move(msg)) { - } + Batch(data msg) : Message(std::move(msg)) {} const vector& batch() const { return get(as_vector()[2]); @@ -183,11 +177,9 @@ public: data fields_data) : Message(Message::Type::LogCreate, {std::move(stream_id), std::move(writer_id), - std::move(writer_info), std::move(fields_data)}) { - } + std::move(writer_info), std::move(fields_data)}) {} - LogCreate(data msg) : Message(std::move(msg)) { - } + LogCreate(data msg) : Message(std::move(msg)) {} const enum_value& stream_id() const { return get(get(as_vector()[2])[0]); @@ -253,11 +245,9 @@ public: data serial_data) : Message(Message::Type::LogWrite, {std::move(stream_id), std::move(writer_id), std::move(path), - std::move(serial_data)}) { - } + std::move(serial_data)}) {} - LogWrite(data msg) : Message(std::move(msg)) { - } + LogWrite(data msg) : Message(std::move(msg)) {} const enum_value& stream_id() const { return get(get(as_vector()[2])[0]); @@ -319,11 +309,9 @@ class IdentifierUpdate : public Message { public: IdentifierUpdate(std::string id_name, data id_value) : Message(Message::Type::IdentifierUpdate, - {std::move(id_name), std::move(id_value)}) { - } + {std::move(id_name), std::move(id_value)}) {} - IdentifierUpdate(data msg) : Message(std::move(msg)) { - } + IdentifierUpdate(data msg) : Message(std::move(msg)) {} const std::string& id_name() const { return get(get(as_vector()[2])[0]); diff --git a/src/BrokerConfig.cmake.in b/src/BrokerConfig.cmake.in index 8443f0317..97562c76d 100644 --- a/src/BrokerConfig.cmake.in +++ b/src/BrokerConfig.cmake.in @@ -1,22 +1,23 @@ -@PACKAGE_INIT@ +@PACKAGE_INIT @ -include(CMakeFindDependencyMacro) + include(CMakeFindDependencyMacro) -set(CMAKE_THREAD_PREFER_PTHREAD ON) -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_dependency(Threads REQUIRED) + set(CMAKE_THREAD_PREFER_PTHREAD ON) set(THREADS_PREFER_PTHREAD_FLAG ON) + find_dependency(Threads REQUIRED) -find_dependency(OpenSSL REQUIRED) + find_dependency(OpenSSL REQUIRED) -find_dependency(CAF @CAF_VERSION@ REQUIRED COMPONENTS core io) + find_dependency(CAF @CAF_VERSION @REQUIRED COMPONENTS core io) -include("${CMAKE_CURRENT_LIST_DIR}/BrokerTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/BrokerTargets.cmake") -set(BROKER_LIBRARY "@BROKER_LIBRARY@" CACHE INTERNAL "name of the Broker library target") + set(BROKER_LIBRARY "@BROKER_LIBRARY@" CACHE INTERNAL + "name of the Broker library target") -function(set_include_dir) - get_target_property(dirs ${BROKER_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES) - set(BROKER_INCLUDE_DIR "${dirs}" CACHE INTERNAL "extra include directories") -endfunction() + function(set_include_dir) get_target_property(dirs ${ + BROKER_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES) + set(BROKER_INCLUDE_DIR "${dirs}" CACHE INTERNAL + "extra include directories") + endfunction() -set_include_dir() + set_include_dir() diff --git a/src/address.cc b/src/address.cc index 877e46105..447d24d9b 100644 --- a/src/address.cc +++ b/src/address.cc @@ -27,8 +27,8 @@ static constexpr bool is_little_endian = true; #endif -constexpr std::array v4_mapped_prefix - = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}}; +constexpr std::array v4_mapped_prefix = { + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}}; auto to_array(const uint32_t* bytes, address::family fam, address::byte_order order) { @@ -99,8 +99,8 @@ bool address::mask(uint8_t top_bits_to_keep) { uint32_t mask[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; auto res = std::ldiv(top_bits_to_keep, 32); if (res.quot < 4) - mask[res.quot] = caf::detail::to_network_order(mask[res.quot] - & ~bit_mask32(32 - res.rem)); + mask[res.quot] = + caf::detail::to_network_order(mask[res.quot] & ~bit_mask32(32 - res.rem)); for (auto i = res.quot + 1; i < 4; ++i) mask[i] = 0; auto p = reinterpret_cast(&bytes()); diff --git a/src/broker-gateway.cc b/src/broker-gateway.cc index 71067585b..0808d8aa3 100644 --- a/src/broker-gateway.cc +++ b/src/broker-gateway.cc @@ -146,8 +146,8 @@ int run(gateway& gw) { }; if (!try_listen("internal.local-port") || !try_listen("external.local-port")) return EXIT_FAILURE; - if (auto peering_failures - = gw.peer(get_or(cfg, "internal.peers", uri_list{}), + if (auto peering_failures = + gw.peer(get_or(cfg, "internal.peers", uri_list{}), get_or(cfg, "internal.peers", uri_list{}), timeout::seconds{get_or(cfg, "retry-interval", size_t{10})}); !peering_failures.empty()) { diff --git a/src/config.hh.in b/src/config.hh.in index 6a024f6c6..3b30c3be8 100644 --- a/src/config.hh.in +++ b/src/config.hh.in @@ -11,27 +11,27 @@ // GCC uses __SANITIZE_ADDRESS__, Clang uses __has_feature #if defined(__SANITIZE_ADDRESS__) - #define BROKER_ASAN +# define BROKER_ASAN #endif #if defined(__has_feature) - #if __has_feature(address_sanitizer) - #define BROKER_ASAN - #endif +# if __has_feature(address_sanitizer) +# define BROKER_ASAN +# endif #endif // FreeBSD and Windows don't support LeakSanitizer #if defined(BROKER_ASAN) && !defined(__FreeBSD__) && !defined(_WIN32) - #include - #define BROKER_LSAN_CHECK(x) __lsan_do_leak_check(x) - #define BROKER_LSAN_ENABLE() __lsan_enable() - #define BROKER_LSAN_DISABLE() __lsan_disable() - #define BROKER_LSAN_IGNORE(x) __lsan_ignore_object(x) +# include +# define BROKER_LSAN_CHECK(x) __lsan_do_leak_check(x) +# define BROKER_LSAN_ENABLE() __lsan_enable() +# define BROKER_LSAN_DISABLE() __lsan_disable() +# define BROKER_LSAN_IGNORE(x) __lsan_ignore_object(x) #else - #define BROKER_LSAN_CHECK(x) - #define BROKER_LSAN_ENABLE() - #define BROKER_LSAN_DISABLE() - #define BROKER_LSAN_IGNORE(x) +# define BROKER_LSAN_CHECK(x) +# define BROKER_LSAN_ENABLE() +# define BROKER_LSAN_DISABLE() +# define BROKER_LSAN_IGNORE(x) #endif // TODO: the "proper" way of implementing the macro would be using diff --git a/src/configuration.cc b/src/configuration.cc index 1c1fb1ffe..7e7aad394 100644 --- a/src/configuration.cc +++ b/src/configuration.cc @@ -63,9 +63,9 @@ auto concat(Ts... xs) { } [[noreturn]] void throw_illegal_log_level(const char* var, const char* cstr) { - auto what - = concat("illegal value for environment variable ", var, ": '", cstr, - "' (legal values: 'trace', 'debug', 'info', 'warning', 'error')"); + auto what = + concat("illegal value for environment variable ", var, ": '", cstr, + "' (legal values: 'trace', 'debug', 'info', 'warning', 'error')"); throw std::invalid_argument(what); } diff --git a/src/data.cc b/src/data.cc index 90b3ee1af..b56fac575 100644 --- a/src/data.cc +++ b/src/data.cc @@ -21,8 +21,8 @@ constexpr const char* data_type_names[] = { }; template -using data_variant_at_t - = std::variant_alternative_t(Type), data_variant>; +using data_variant_at_t = + std::variant_alternative_t(Type), data_variant>; // Make sure the static_cast in data::get_type is safe. using std::is_same_v; diff --git a/src/detail/sqlite_backend.cc b/src/detail/sqlite_backend.cc index bdd45aebd..c12bd1ac4 100644 --- a/src/detail/sqlite_backend.cc +++ b/src/detail/sqlite_backend.cc @@ -222,11 +222,9 @@ struct sqlite_backend::impl { }; sqlite_backend::sqlite_backend(backend_options opts) - : impl_{std::make_unique(std::move(opts))} { -} + : impl_{std::make_unique(std::move(opts))} {} -sqlite_backend::~sqlite_backend() { -} +sqlite_backend::~sqlite_backend() {} bool sqlite_backend::init_failed() const { return !impl_->db; diff --git a/src/endpoint.cc b/src/endpoint.cc index d922da62c..4b35c285d 100644 --- a/src/endpoint.cc +++ b/src/endpoint.cc @@ -105,8 +105,8 @@ struct async_helper_state { }; template -using async_helper_actor - = caf::stateful_actor>; +using async_helper_actor = + caf::stateful_actor>; caf::actor_system_config& nat_cfg(configuration& cfg) { internal::configuration_access helper{&cfg}; @@ -745,10 +745,9 @@ uint16_t endpoint::web_socket_listen(const std::string& address, uint16_t port, internal::web_socket::connect_event_t& ev) { auto& [pull, push] = ev; auto user_agent = caf::get_or(hdr, "web-socket.fields.User-Agent", "null"); - auto addr - = network_info{caf::get_or(hdr, "web-socket.remote-address", "unknown"), - caf::get_or(hdr, "web-socket.remote-port", uint16_t{0}), - 0s}; + auto addr = + network_info{caf::get_or(hdr, "web-socket.remote-address", "unknown"), + caf::get_or(hdr, "web-socket.remote-port", uint16_t{0}), 0s}; BROKER_INFO("new JSON client with address" << addr << "and user agent" << user_agent); using impl_t = internal::json_client_actor; diff --git a/src/error.cc b/src/error.cc index 3552b17f8..34f39d1e9 100644 --- a/src/error.cc +++ b/src/error.cc @@ -132,8 +132,8 @@ uint16_t error::category() const noexcept { const std::string* error::message() const noexcept { auto& msg = native(*this).context(); - if (auto v1 - = caf::make_const_typed_message_view(msg)) + if (auto v1 = + caf::make_const_typed_message_view(msg)) return std::addressof(get<1>(v1)); else if (auto v2 = caf::make_const_typed_message_view(msg)) return std::addressof(get<0>(v2)); diff --git a/src/internal/clone_actor.cc b/src/internal/clone_actor.cc index 9aea844f5..4a6852617 100644 --- a/src/internal/clone_actor.cc +++ b/src/internal/clone_actor.cc @@ -314,9 +314,10 @@ void clone_state::send(producer_type* ptr, const entity_id&, BROKER_TRACE(BROKER_ARG(what)); BROKER_DEBUG("send attach_writer_command with offset" << what.offset); auto msg = make_command_message( - master_topic, internal_command{0, id, master_id, - attach_writer_command{ - what.offset, what.heartbeat_interval}}); + master_topic, + internal_command{0, id, master_id, + attach_writer_command{what.offset, + what.heartbeat_interval}}); self->send(core, atom::publish_v, move(msg)); } diff --git a/src/internal/connector.cc b/src/internal/connector.cc index c97ccc027..aad50a24c 100644 --- a/src/internal/connector.cc +++ b/src/internal/connector.cc @@ -447,22 +447,22 @@ class pipe_reader { switch (msg_type) { case connector_msg::connect: { BROKER_DEBUG("received connect event"); - auto&& [eid, addr] - = from_source(src); + auto&& [eid, addr] = + from_source(src); mgr.connect(eid, addr); break; } case connector_msg::drop: { BROKER_DEBUG("received drop event"); - auto&& [eid, addr] - = from_source(src); + auto&& [eid, addr] = + from_source(src); mgr.drop(eid, addr); break; } case connector_msg::listen: { BROKER_DEBUG("received listen event"); - auto&& [eid, host, port, reuse_addr] - = from_source(src); + auto&& [eid, host, port, reuse_addr] = + from_source(src); mgr.listen(eid, host, port, reuse_addr); break; } diff --git a/src/internal/core_actor.cc b/src/internal/core_actor.cc index 0608b70c2..1a54cea78 100644 --- a/src/internal/core_actor.cc +++ b/src/internal/core_actor.cc @@ -427,8 +427,8 @@ void core_actor_state::emit(endpoint_info ep, EnumConstant code, str = topic::statuses_str; else str = topic::errors_str; - using factory - = std::conditional_t, status, error_factory>; + using factory = + std::conditional_t, status, error_factory>; // Generate a data message from the converted content and address it to this // node only. This ensures that the data remains visible locally only. auto val = factory::make(code, std::move(ep), msg); @@ -680,27 +680,27 @@ core_actor_state::get_or_init_data_outputs() { if (!data_outputs) { BROKER_DEBUG("create data outputs"); // Hook into the central merge point. - data_outputs - = central_merge - ->as_observable() - // Drop everything but data messages and only process messages that - // are not meant for another peer. - .filter([this](const node_message& msg) { - // Note: local subscribers do not receive messages from local - // publishers. Except when the message explicitly says otherwise by - // setting receiver == id. This is the case for messages that were - // published via `(atom::publish, atom::local, ...)` message. - auto receiver = get_receiver(msg); - return get_type(msg) == packed_message_type::data - && (get_sender(msg) != id || receiver == id) - && (!receiver || receiver == id); - }) - // Deserialize payload and wrap it into an actual data message. - .flat_map_optional([this](const node_message& msg) { - return unpack(get_packed_message(msg)); - }) - // Convert this blueprint to an actual observable. - .as_observable(); + data_outputs = + central_merge + ->as_observable() + // Drop everything but data messages and only process messages that + // are not meant for another peer. + .filter([this](const node_message& msg) { + // Note: local subscribers do not receive messages from local + // publishers. Except when the message explicitly says otherwise by + // setting receiver == id. This is the case for messages that were + // published via `(atom::publish, atom::local, ...)` message. + auto receiver = get_receiver(msg); + return get_type(msg) == packed_message_type::data + && (get_sender(msg) != id || receiver == id) + && (!receiver || receiver == id); + }) + // Deserialize payload and wrap it into an actual data message. + .flat_map_optional([this](const node_message& msg) { + return unpack(get_packed_message(msg)); + }) + // Convert this blueprint to an actual observable. + .as_observable(); } return data_outputs; } @@ -710,22 +710,22 @@ core_actor_state::get_or_init_command_outputs() { if (!command_outputs) { BROKER_DEBUG("create command outputs"); // Hook into the central merge point. - command_outputs - = central_merge - ->as_observable() - // Drop everything but command messages and only process messages that - // are not meant for another peer. - .filter([this](const node_message& msg) { - auto receiver = get_receiver(msg); - return get_type(msg) == packed_message_type::command - && (!receiver || receiver == id); - }) - // Deserialize payload and wrap it into an actual command message. - .flat_map_optional([this](const node_message& msg) { - return unpack(get_packed_message(msg)); - }) - // Convert this blueprint to an actual observable. - .as_observable(); + command_outputs = + central_merge + ->as_observable() + // Drop everything but command messages and only process messages that + // are not meant for another peer. + .filter([this](const node_message& msg) { + auto receiver = get_receiver(msg); + return get_type(msg) == packed_message_type::command + && (!receiver || receiver == id); + }) + // Deserialize payload and wrap it into an actual command message. + .flat_map_optional([this](const node_message& msg) { + return unpack(get_packed_message(msg)); + }) + // Convert this blueprint to an actual observable. + .as_observable(); } return command_outputs; } diff --git a/src/internal/flare_actor.cc b/src/internal/flare_actor.cc index bd1712d7d..bbb490e6c 100644 --- a/src/internal/flare_actor.cc +++ b/src/internal/flare_actor.cc @@ -11,8 +11,7 @@ namespace broker::internal { flare_actor::flare_actor(caf::actor_config& sys) - : blocking_actor{sys}, flare_count_{0} { -} + : blocking_actor{sys}, flare_count_{0} {} void flare_actor::launch(caf::execution_unit*, bool, bool) { // Nothing todo here since we only extract messages via receive() calls. diff --git a/src/internal/master_resolver.cc b/src/internal/master_resolver.cc index 135a4a994..74a8c4f0c 100644 --- a/src/internal/master_resolver.cc +++ b/src/internal/master_resolver.cc @@ -38,7 +38,8 @@ caf::behavior master_resolver(master_resolver_actor* self) { BROKER_DEBUG("resolver found master:" << master); self->send(self->state.who_asked, atom::master_v, std::move(master)); self->quit(); - }}; + }, + }; } } // namespace broker::internal diff --git a/src/internal/prometheus.cc b/src/internal/prometheus.cc index 8b8476d2e..2820ca000 100644 --- a/src/internal/prometheus.cc +++ b/src/internal/prometheus.cc @@ -22,9 +22,9 @@ constexpr size_t max_request_size = 512 * 1024; constexpr string_view valid_request_start = "GET /metrics HTTP/1."; // HTTP response for requests that exceed the size limit. -constexpr string_view request_too_large - = "HTTP/1.1 413 Request Entity Too Large\r\n" - "Connection: Closed\r\n\r\n"; +constexpr string_view request_too_large = + "HTTP/1.1 413 Request Entity Too Large\r\n" + "Connection: Closed\r\n\r\n"; // HTTP response for requests that don't start with "GET /metrics HTTP/1". constexpr string_view request_not_supported = "HTTP/1.1 501 Not Implemented\r\n" diff --git a/src/internal/scoped_flare_actor.cc b/src/internal/scoped_flare_actor.cc index 7eaccbcfb..59e014371 100644 --- a/src/internal/scoped_flare_actor.cc +++ b/src/internal/scoped_flare_actor.cc @@ -5,8 +5,9 @@ namespace broker::internal { scoped_flare_actor::scoped_flare_actor(caf::actor_system& sys) : context_{&sys} { caf::actor_config cfg{&context_}; - self_ = caf::make_actor( - sys.next_actor_id(), sys.node(), &sys, cfg); + self_ = + caf::make_actor(sys.next_actor_id(), + sys.node(), &sys, cfg); ptr()->is_registered(true); } diff --git a/src/internal/web_socket.cc b/src/internal/web_socket.cc index eecc7fead..44bebc767 100644 --- a/src/internal/web_socket.cc +++ b/src/internal/web_socket.cc @@ -69,9 +69,9 @@ class acceptor_factory { caf::net::socket_manager_ptr make(Socket fd, caf::net::multiplexer* mpx) { using trait_t = caf::detail::ws_accept_trait; using value_type = typename trait_t::value_type; - using app_t - = caf::net::message_flow_bridge; + using app_t = + caf::net::message_flow_bridge; using caf::net::openssl_transport; using stack_t = openssl_transport>; auto policy = caf::net::openssl::policy::make(ctx_, fd); @@ -133,8 +133,8 @@ expected launch(caf::actor_system& sys, openssl_options_ptr ssl_cfg, // Callback for connecting the flows. using consumer_res_t = caf::async::consumer_resource; using producer_res_t = caf::async::producer_resource; - using res_t - = caf::expected>; + using res_t = + caf::expected>; auto on_request = [cb = std::move(on_connect), allowed_path](const caf::settings& hdr) { auto path = caf::get_or(hdr, "web-socket.path", ""); diff --git a/src/network_info.cc b/src/network_info.cc index 7e8b552c0..f26d81073 100644 --- a/src/network_info.cc +++ b/src/network_info.cc @@ -13,8 +13,7 @@ namespace broker { network_info::network_info(std::string addr, uint16_t port, timeout::seconds retry) - : address{std::move(addr)}, port{port}, retry{retry} { -} + : address{std::move(addr)}, port{port}, retry{retry} {} bool operator==(const network_info& x, const network_info& y) { return x.address == y.address && x.port == y.port; diff --git a/src/port.cc b/src/port.cc index 56240a677..866f15bb4 100644 --- a/src/port.cc +++ b/src/port.cc @@ -11,11 +11,9 @@ namespace broker { -port::port() : num_{0}, proto_{protocol::unknown} { -} +port::port() : num_{0}, proto_{protocol::unknown} {} -port::port(number_type n, protocol p) : num_{n}, proto_{p} { -} +port::port(number_type n, protocol p) : num_{n}, proto_{p} {} port::number_type port::number() const { return num_; diff --git a/src/store.cc b/src/store.cc index 64c869787..5ebd597de 100644 --- a/src/store.cc +++ b/src/store.cc @@ -188,8 +188,8 @@ store::store(endpoint_id this_peer, worker frontend, std::string name) { return; } auto hdl = native(frontend); - detail::shared_store_state_ptr ptr - = std::make_shared(this_peer, std::move(name), hdl); + detail::shared_store_state_ptr ptr = + std::make_shared(this_peer, std::move(name), hdl); state_ = ptr; caf::anon_send(hdl, atom::increment_v, std::move(ptr)); } @@ -407,25 +407,28 @@ void store::put(data key, data value, std::optional expiry) { void store::erase(data key) { with_state([&](state_impl& st) { - st.anon_send(atom::local_v, internal_command_variant{erase_command{ - std::move(key), st.frontend_id()}}); + st.anon_send(atom::local_v, + internal_command_variant{ + erase_command{std::move(key), st.frontend_id()}}); }); } void store::add(data key, data value, data::type init_type, std::optional expiry) { with_state([&](state_impl& st) { - st.anon_send(atom::local_v, internal_command_variant{add_command{ - std::move(key), std::move(value), init_type, - expiry, st.frontend_id()}}); + st.anon_send(atom::local_v, + internal_command_variant{ + add_command{std::move(key), std::move(value), init_type, + expiry, st.frontend_id()}}); }); } void store::subtract(data key, data value, std::optional expiry) { with_state([&](state_impl& st) { - st.anon_send(atom::local_v, internal_command_variant{subtract_command{ - std::move(key), std::move(value), expiry, - st.frontend_id()}}); + st.anon_send(atom::local_v, + internal_command_variant{ + subtract_command{std::move(key), std::move(value), expiry, + st.frontend_id()}}); }); } diff --git a/src/subnet.cc b/src/subnet.cc index 0a9771cd4..5223b906e 100644 --- a/src/subnet.cc +++ b/src/subnet.cc @@ -11,8 +11,7 @@ namespace broker { -subnet::subnet() : len_(0) { -} +subnet::subnet() : len_(0) {} subnet::subnet(address addr, uint8_t length) : net_(std::move(addr)), len_(length) { diff --git a/src/telemetry/metric_registry.cc b/src/telemetry/metric_registry.cc index bde48f8f8..e1c1837ce 100644 --- a/src/telemetry/metric_registry.cc +++ b/src/telemetry/metric_registry.cc @@ -38,17 +38,19 @@ dbl_counter_fam(metric_registry_impl* impl, std::string_view pre, return impl->dbl_counter_fam(pre, name, labels, helptext, unit, is_sum); } -int_gauge_family_hdl* -int_gauge_fam(metric_registry_impl* impl, std::string_view pre, - std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum) { +int_gauge_family_hdl* int_gauge_fam(metric_registry_impl* impl, + std::string_view pre, std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, bool is_sum) { return impl->int_gauge_fam(pre, name, labels, helptext, unit, is_sum); } -dbl_gauge_family_hdl* -dbl_gauge_fam(metric_registry_impl* impl, std::string_view pre, - std::string_view name, span labels, - std::string_view helptext, std::string_view unit, bool is_sum) { +dbl_gauge_family_hdl* dbl_gauge_fam(metric_registry_impl* impl, + std::string_view pre, std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, bool is_sum) { return impl->dbl_gauge_fam(pre, name, labels, helptext, unit, is_sum); } @@ -85,8 +87,7 @@ metric_registry::metric_registry(metric_registry&& other) noexcept } metric_registry::metric_registry(const metric_registry& other) noexcept - : metric_registry(other.impl_, true) { -} + : metric_registry(other.impl_, true) {} metric_registry& metric_registry::operator=(metric_registry&& other) noexcept { std::swap(impl_, other.impl_); @@ -145,22 +146,24 @@ class impl_base : public metric_registry_impl { // nop } - int_counter_family_hdl* - int_counter_fam(std::string_view pre, std::string_view name, - span labels, - std::string_view helptext, std::string_view unit, - bool is_sum) override { + int_counter_family_hdl* int_counter_fam(std::string_view pre, + std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, + bool is_sum) override { return internal::with_native_labels(labels, [=](auto xs) { auto ptr = reg_->counter_family(pre, name, xs, helptext, unit, is_sum); return reinterpret_cast(ptr); }); } - dbl_counter_family_hdl* - dbl_counter_fam(std::string_view pre, std::string_view name, - span labels, - std::string_view helptext, std::string_view unit, - bool is_sum) override { + dbl_counter_family_hdl* dbl_counter_fam(std::string_view pre, + std::string_view name, + span labels, + std::string_view helptext, + std::string_view unit, + bool is_sum) override { return internal::with_native_labels(labels, [=](auto xs) { auto ptr = reg_->counter_family(pre, name, xs, helptext, unit, is_sum); diff --git a/tests/benchmark/broker-cluster-benchmark.cc b/tests/benchmark/broker-cluster-benchmark.cc index 84dac3ece..b23b78a84 100644 --- a/tests/benchmark/broker-cluster-benchmark.cc +++ b/tests/benchmark/broker-cluster-benchmark.cc @@ -834,8 +834,8 @@ int generate_config(string_list directories) { if (auto val = caf::get_if(std::addressof(*conf), "broker.forward")) node.disable_forwarding = !*val; else - node.disable_forwarding - = caf::get_or(*conf, "broker.disable-forwarding", false); + node.disable_forwarding = + caf::get_or(*conf, "broker.disable-forwarding", false); } else { err::println("unable to parse ", quoted{conf_file}, ": ", to_string(conf.error())); @@ -870,8 +870,8 @@ int generate_config(string_list directories) { using output_map = std::map; std::map outputs; for (const auto& node : nodes) { - auto gptr - = broker::internal::make_generator_file_reader(node.generator_file); + auto gptr = + broker::internal::make_generator_file_reader(node.generator_file); if (gptr == nullptr) { err::println("unable to open generator file: ", node.generator_file); return EXIT_FAILURE; diff --git a/tests/cpp/core.cc b/tests/cpp/core.cc index 963abf9e3..da44324ed 100644 --- a/tests/cpp/core.cc +++ b/tests/cpp/core.cc @@ -47,31 +47,31 @@ struct driver_state { caf::behavior driver(caf::stateful_actor* self, const caf::actor& sink, bool restartable) { self->state.restartable = restartable; - auto ptr - = attach_stream_source( - self, - // Destination. - sink, - // Initialize send buffer with 10 elements. - [](caf::unit_t&) { - // nop - }, - // Get next element. - [=](caf::unit_t&, caf::downstream& out, size_t num) { - auto& xs = self->state.xs; - auto n = std::min(num, xs.size()); - if (n == 0) - return; - for (size_t i = 0u; i < n; ++i) - out.push(xs[i]); - xs.erase(xs.begin(), xs.begin() + static_cast(n)); - }, - // Did we reach the end?. - [=](const caf::unit_t&) { - auto& st = self->state; - return !st.restartable && st.xs.empty(); - }) - .ptr(); + auto ptr = + attach_stream_source( + self, + // Destination. + sink, + // Initialize send buffer with 10 elements. + [](caf::unit_t&) { + // nop + }, + // Get next element. + [=](caf::unit_t&, caf::downstream& out, size_t num) { + auto& xs = self->state.xs; + auto n = std::min(num, xs.size()); + if (n == 0) + return; + for (size_t i = 0u; i < n; ++i) + out.push(xs[i]); + xs.erase(xs.begin(), xs.begin() + static_cast(n)); + }, + // Did we reach the end?. + [=](const caf::unit_t&) { + auto& st = self->state; + return !st.restartable && st.xs.empty(); + }) + .ptr(); return { [=](atom::restart) { self->state.reset(); @@ -180,8 +180,8 @@ CAF_TEST(local_peers) { sched.prioritize(leaf); consume_message(); self->receive([](const buf& xs) { - auto expected - = data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); + auto expected = + data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); CAF_REQUIRE_EQUAL(xs, expected); }); CAF_MESSAGE("send message 'directly' from core1 to core2 (bypass streaming)"); @@ -317,8 +317,8 @@ CAF_TEST(triangle_peering) { run(); // Check log of the consumers. using buf = std::vector; - auto expected - = data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); + auto expected = + data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); for (auto& leaf : {leaf2, leaf3}) { self->send(leaf, atom::get_v); sched.prioritize(leaf); @@ -385,8 +385,8 @@ CAF_TEST(sequenced_peering) { run(); // Check log of the consumer on core2. using buf = std::vector; - auto expected - = data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); + auto expected = + data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); self->send(leaf1, atom::get_v); sched.prioritize(leaf1); consume_message(); @@ -640,8 +640,8 @@ CAF_TEST(remote_peers_setup1) { earth.self->send(leaf, atom::get_v); exec_all(); earth.self->receive([](const buf& xs) { - auto expected - = data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); + auto expected = + data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); CAF_REQUIRE_EQUAL(xs, expected); }); anon_send_exit(core1, caf::exit_reason::user_shutdown); @@ -699,8 +699,8 @@ CAF_TEST(remote_peers_setup2) { mars.sched.prioritize(leaf); mars.consume_message(); mars.self->receive([](const buf& xs) { - auto expected - = data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); + auto expected = + data_msgs({{"b", true}, {"b", false}, {"b", true}, {"b", false}}); CAF_REQUIRE_EQUAL(xs, expected); }); CAF_MESSAGE("shutdown core actors"); diff --git a/tests/cpp/integration.cc b/tests/cpp/integration.cc index 94335ed77..c6e8c7ff3 100644 --- a/tests/cpp/integration.cc +++ b/tests/cpp/integration.cc @@ -213,8 +213,7 @@ struct triangle_fixture : global_fixture { peer_fixture earth; triangle_fixture() - : mercury(this, "mercury"), venus(this, "venus"), earth(this, "earth") { - } + : mercury(this, "mercury"), venus(this, "venus"), earth(this, "earth") {} // Connect mercury to venus and earth. void connect_peers() { diff --git a/tests/cpp/internal/meta_data_writer.cc b/tests/cpp/internal/meta_data_writer.cc index f6c2a72f4..007a8df89 100644 --- a/tests/cpp/internal/meta_data_writer.cc +++ b/tests/cpp/internal/meta_data_writer.cc @@ -200,11 +200,11 @@ CAF_TEST(put_command) { } CAF_TEST(put_unique_command) { - auto cmd - = internal_command{0, - {}, - put_unique_command{data{"hello"}, data{"broker"}, - std::nullopt, entity_id::nil(), 0}}; + auto cmd = + internal_command{0, + {}, + put_unique_command{data{"hello"}, data{"broker"}, + std::nullopt, entity_id::nil(), 0}}; push(cmd); CHECK_EQUAL(pull(), internal_command::type::put_unique_command); @@ -227,11 +227,11 @@ CAF_TEST(erase_command) { } CAF_TEST(add_command) { - auto cmd = internal_command{0, - {}, - add_command{data{"key"}, data{"value"}, - data::type::table, std::nullopt, - entity_id::nil()}}; + auto cmd = + internal_command{0, + {}, + add_command{data{"key"}, data{"value"}, data::type::table, + std::nullopt, entity_id::nil()}}; push(cmd); CHECK_EQUAL(pull(), internal_command::type::add_command); diff --git a/tests/cpp/radix_tree.cc b/tests/cpp/radix_tree.cc index 3b37e7465..87f83be1d 100644 --- a/tests/cpp/radix_tree.cc +++ b/tests/cpp/radix_tree.cc @@ -61,28 +61,28 @@ unsigned char key1[300] = { 207, 97, 151, 88, 237, 246, 208, 8, 18, 255, 255, 255, 219, 191, 198, 134, 5, 223, 212, 72, 44, 208, 250, 180, 14, 1, 0, 0, 8, '\0'}; -unsigned char key2[303] - = {16, 0, 0, 0, 7, 10, 0, 0, 0, 2, 17, 10, 0, 0, 0, - 120, 10, 0, 0, 0, 120, 10, 0, 0, 0, 216, 10, 0, 0, 0, - 202, 10, 0, 0, 0, 194, 10, 0, 0, 0, 224, 10, 0, 0, 0, - 230, 10, 0, 0, 0, 210, 10, 0, 0, 0, 206, 10, 0, 0, 0, - 208, 10, 0, 0, 0, 232, 10, 0, 0, 0, 124, 10, 0, 0, 0, - 124, 2, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, 251, 173, 202, - 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, 8, 18, 182, - 92, 236, 147, 171, 101, 150, 195, 112, 185, 218, 108, 246, 139, 164, 234, - 195, 58, 177, 0, 8, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, - 251, 173, 202, 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, - 8, 18, 180, 93, 46, 151, 9, 212, 190, 95, 102, 178, 217, 44, 178, - 235, 29, 190, 218, 8, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, - 251, 173, 202, 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, - 8, 18, 180, 93, 46, 151, 9, 212, 190, 95, 102, 183, 219, 229, 214, - 59, 125, 182, 71, 108, 180, 220, 238, 150, 91, 117, 150, 201, 84, 183, - 128, 8, 16, 0, 0, 0, 3, 12, 185, 89, 44, 213, 251, 133, 178, - 195, 105, 183, 87, 237, 150, 155, 165, 150, 229, 97, 182, 0, 8, 18, - 161, 91, 239, 50, 10, 61, 150, 223, 114, 179, 217, 64, 8, 12, 186, - 219, 172, 150, 91, 53, 166, 221, 101, 178, 0, 8, 18, 255, 255, 255, - 219, 191, 198, 134, 5, 208, 212, 72, 44, 208, 250, 180, 14, 1, 0, - 0, 8, '\0'}; +unsigned char key2[303] = { + 16, 0, 0, 0, 7, 10, 0, 0, 0, 2, 17, 10, 0, 0, 0, + 120, 10, 0, 0, 0, 120, 10, 0, 0, 0, 216, 10, 0, 0, 0, + 202, 10, 0, 0, 0, 194, 10, 0, 0, 0, 224, 10, 0, 0, 0, + 230, 10, 0, 0, 0, 210, 10, 0, 0, 0, 206, 10, 0, 0, 0, + 208, 10, 0, 0, 0, 232, 10, 0, 0, 0, 124, 10, 0, 0, 0, + 124, 2, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, 251, 173, 202, + 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, 8, 18, 182, + 92, 236, 147, 171, 101, 150, 195, 112, 185, 218, 108, 246, 139, 164, 234, + 195, 58, 177, 0, 8, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, + 251, 173, 202, 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, + 8, 18, 180, 93, 46, 151, 9, 212, 190, 95, 102, 178, 217, 44, 178, + 235, 29, 190, 218, 8, 16, 0, 0, 0, 2, 12, 185, 89, 44, 213, + 251, 173, 202, 211, 95, 185, 89, 110, 118, 251, 173, 202, 199, 101, 0, + 8, 18, 180, 93, 46, 151, 9, 212, 190, 95, 102, 183, 219, 229, 214, + 59, 125, 182, 71, 108, 180, 220, 238, 150, 91, 117, 150, 201, 84, 183, + 128, 8, 16, 0, 0, 0, 3, 12, 185, 89, 44, 213, 251, 133, 178, + 195, 105, 183, 87, 237, 150, 155, 165, 150, 229, 97, 182, 0, 8, 18, + 161, 91, 239, 50, 10, 61, 150, 223, 114, 179, 217, 64, 8, 12, 186, + 219, 172, 150, 91, 53, 166, 221, 101, 178, 0, 8, 18, 255, 255, 255, + 219, 191, 198, 134, 5, 208, 212, 72, 44, 208, 250, 180, 14, 1, 0, + 0, 8, '\0'}; } // namespace diff --git a/tests/cpp/ssl.cc b/tests/cpp/ssl.cc index cbb841065..c31fda91e 100644 --- a/tests/cpp/ssl.cc +++ b/tests/cpp/ssl.cc @@ -50,8 +50,7 @@ struct peer_fixture { // Initializes this peer and registers it at parent. peer_fixture(std::string peer_name, configuration config) - : name(std::move(peer_name)), ep(std::move(config)) { - } + : name(std::move(peer_name)), ep(std::move(config)) {} }; // A fixture for testing SSL authentication. @@ -65,8 +64,7 @@ struct ssl_auth_fixture { : mercury_auth("mercury_auth", make_config("1")), venus_auth("venus_auth", make_config("2")), earth_no_auth("earth_no_auth", make_config("")), - earth_wrong_auth("earth_wrong_auth", make_config("self-signed")) { - } + earth_wrong_auth("earth_wrong_auth", make_config("self-signed")) {} }; } // namespace diff --git a/tests/cpp/system/peering.cc b/tests/cpp/system/peering.cc index dcf52cf41..c673ee891 100644 --- a/tests/cpp/system/peering.cc +++ b/tests/cpp/system/peering.cc @@ -254,10 +254,10 @@ TEST(a full mesh emits endpoint_discovered and peer_added for all nodes) { lines.emplace_back("hello from " + std::to_string(i)); hellos.emplace_back(lines); } - auto sequence - = std::vector{"endpoint_discovered"_a, "peer_added"_a, - alternative{"peer_lost", "peer_removed"}, - "endpoint_unreachable"_a}; + auto sequence = + std::vector{"endpoint_discovered"_a, "peer_added"_a, + alternative{"peer_lost", "peer_removed"}, + "endpoint_unreachable"_a}; // Check all endpoints. for (size_t index = 0; index != num_endpoints; ++index) { for (size_t i = 0; i != num_endpoints; ++i) diff --git a/tests/micro-benchmark/include/main.hh b/tests/micro-benchmark/include/main.hh index 7ef2fd3a8..221ba127c 100644 --- a/tests/micro-benchmark/include/main.hh +++ b/tests/micro-benchmark/include/main.hh @@ -22,8 +22,8 @@ class uuid_multipath; class uuid_multipath_group; class uuid_multipath_node; -using node_message_content - = broker::variant; +using node_message_content = + broker::variant; using uuid_node_message = caf::cow_tuple; @@ -125,8 +125,8 @@ public: private: template - std::pair - emplace_impl(uuid id, MakeNewNode make_new_node); + std::pair emplace_impl(uuid id, + MakeNewNode make_new_node); size_t size_ = 0; uuid_multipath_node* first_ = nullptr; @@ -202,14 +202,13 @@ private: } template - bool - load_children(broker::detail::monotonic_buffer_resource& mem, Inspector& f) { + bool load_children(broker::detail::monotonic_buffer_resource& mem, + Inspector& f) { size_t n = 0; if (f.begin_sequence(n)) { for (size_t i = 0; i < n; ++i) { - auto child = broker::detail::new_instance(mem, - uuid{}, - false); + auto child = + broker::detail::new_instance(mem, uuid{}, false); if (!child->load(mem, f)) { return false; } else if (!down_.emplace(child)) { diff --git a/tests/micro-benchmark/src/routing-table.cc b/tests/micro-benchmark/src/routing-table.cc index 0156feaef..3a2cec107 100644 --- a/tests/micro-benchmark/src/routing-table.cc +++ b/tests/micro-benchmark/src/routing-table.cc @@ -28,8 +28,8 @@ struct linear_routing_table_row { linear_routing_table_row(linear_routing_table_row&&) = default; linear_routing_table_row(const linear_routing_table_row&) = default; linear_routing_table_row& operator=(linear_routing_table_row&&) = default; - linear_routing_table_row& operator=(const linear_routing_table_row&) - = default; + linear_routing_table_row& + operator=(const linear_routing_table_row&) = default; explicit linear_routing_table_row(endpoint_id id) : id(std::move(id)) { versioned_paths.reserve(32);