Skip to content

Conversation

@MarioIvancik
Copy link
Member

@MarioIvancik MarioIvancik commented Jul 18, 2025

https://youtrack.bringauto.com/issue/BAF-1122/Module-Gateway-performance

Summary by CodeRabbit

  • New Features

    • Added support for a new "DUMMY" protocol type, including a dummy communication channel.
    • Introduced a configurable minimum logger verbosity level, set at build time for improved performance.
  • Improvements

    • Enhanced const-correctness across many interfaces for increased code safety and clarity.
    • Switched various internal containers from ordered maps to unordered maps for improved lookup performance.
    • Added a method to retrieve the remote endpoint address for connections.
    • Optimized logger configuration and compile-time filtering.
    • Improved code clarity and reduced redundant lookups in connection and external client handling.
    • Centralized remote endpoint address retrieval in server logs.
    • Simplified connection initialization logic in MQTT communication.
  • Bug Fixes

    • Corrected typos and improved parameter naming in documentation and comments.
  • Documentation

    • Updated README and code comments to reflect new features and clarify usage.
  • Tests

    • Extended unit tests for new protocol type and updated logger tests for verbosity configuration.

@MarioIvancik MarioIvancik self-assigned this Jul 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 18, 2025

Walkthrough

This update introduces a new compile-time logger verbosity option, adds a logger wrapper for compile-time verbosity filtering, and propagates const-correctness and container type changes (from std::map to std::unordered_map) throughout the codebase. It also adds a new dummy protocol type and communication channel, updates related documentation, and improves code clarity and immutability.

Changes

Files/Group Change Summary
CMakeLists.txt, README.md Added MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY CMake option and documented it.
include/bringauto/settings/LoggerId.hpp, include/bringauto/settings/LoggerWrapper.hpp, source/bringauto/settings/LoggerId.cpp Introduced LoggerWrapper template for compile-time verbosity filtering; updated logger aliasing and macro logic; added compile-time validation of verbosity macro.
main.cpp, test/include/InternalServerTests.hpp, test/include/ErrorAggregatorTests.hpp, test/include/ExternalConnectionTests.hpp, test/include/StatusAggregatorTests.hpp Logger initialization now uses compile-time verbosity macro; added stream sync disable for performance.
include/bringauto/common_utils/EnumUtils.hpp, source/bringauto/common_utils/EnumUtils.cpp, test/source/EnumUtilsTests.cpp Converted enum-to-string functions to constexpr returning std::string_view, used constants, added DUMMY protocol support, updated tests.
include/bringauto/settings/Constants.hpp Added DUMMY protocol string constant.
include/bringauto/structures/ExternalConnectionSettings.hpp, include/bringauto/structures/ModuleLibrary.hpp, include/bringauto/settings/Settings.hpp, test/include/testing_utils/ConfigMock.hpp Changed container types from std::map to std::unordered_map for protocol settings, module paths, and related structures.
include/bringauto/external_client/connection/communication/DummyCommunication.hpp, source/bringauto/external_client/connection/communication/DummyCommunication.cpp Added new DummyCommunication class implementing dummy communication channel for the DUMMY protocol.
include/bringauto/external_client/ExternalClient.hpp, source/bringauto/external_client/ExternalClient.cpp Added DUMMY protocol support, improved const-correctness, updated container usage, and variable naming.
include/bringauto/external_client/connection/ExternalConnection.hpp, source/bringauto/external_client/connection/ExternalConnection.cpp Improved const-correctness, switched to unordered_map, updated method signatures, and replaced redundant map lookups with iterators.
include/bringauto/external_client/ErrorAggregator.hpp, source/bringauto/external_client/ErrorAggregator.cpp Marked methods as const, improved const-correctness, removed unused includes.
include/bringauto/external_client/connection/communication/ICommunicationChannel.hpp Changed constructor to take settings by value and move.
include/bringauto/external_client/connection/communication/MqttCommunication.hpp, source/bringauto/external_client/connection/communication/MqttCommunication.cpp Removed unused includes, simplified connection logic.
include/bringauto/external_client/connection/messages/NotAckedStatus.hpp, source/bringauto/external_client/connection/messages/NotAckedStatus.cpp Made timeout handler method const, updated constructor signature to take status by value and move.
include/bringauto/external_client/connection/messages/SentMessagesHandler.hpp, source/bringauto/external_client/connection/messages/SentMessagesHandler.cpp Minor comment and constness improvements.
include/bringauto/internal_server/InternalServer.hpp, source/bringauto/internal_server/InternalServer.cpp Improved comments, marked methods as const, centralized remote endpoint address retrieval, added socket option no_delay.
include/bringauto/modules/Buffer.hpp Removed unused includes, fixed comment typo.
include/bringauto/modules/ModuleHandler.hpp, source/bringauto/modules/ModuleHandler.cpp Added const-correctness to interface and implementation, updated includes, and local variable immutability.
include/bringauto/modules/ModuleManagerLibraryHandler.hpp, source/bringauto/modules/ModuleManagerLibraryHandler.cpp Added const-correctness to methods and parameters, updated logger alias, and improved local variable constness.
include/bringauto/modules/StatusAggregator.hpp, source/bringauto/modules/StatusAggregator.cpp, test/source/StatusAggregatorTests.cpp Improved const-correctness, parameter naming, added required includes, and modernized container insertion.
include/bringauto/common_utils/ProtobufUtils.hpp, source/bringauto/common_utils/ProtobufUtils.cpp Improved const-correctness, used move semantics, optimized buffer copying, removed unused includes.
include/bringauto/settings/SettingsParser.hpp, source/bringauto/settings/SettingsParser.cpp Added const-correctness, DUMMY protocol support, improved JSON handling and safety checks.
include/bringauto/structures/Connection.hpp Added method to retrieve remote endpoint address as string.
include/bringauto/structures/DeviceIdentification.hpp Fixed comment typo.
include/bringauto/structures/InternalClientMessage.hpp, include/bringauto/structures/ModuleHandlerMessage.hpp, include/bringauto/structures/StatusAggregatorDeviceState.hpp, include/bringauto/modules/Buffer.hpp, include/bringauto/structures/ReconnectQueueItem.hpp, include/bringauto/structures/ThreadTimer.hpp Removed unused includes, fixed typos, improved parameter naming and constness.
source/bringauto/structures/ModuleLibrary.cpp Updated to use unordered_map and modern map methods like contains.
source/bringauto/structures/StatusAggregatorDeviceState.cpp Updated includes, improved parameter naming, and replaced deprecated includes.
Dockerfile Updated MISSION_MODULE_VERSION argument from v1.2.12 to v1.2.13.

Sequence Diagram(s)

sequenceDiagram
    participant Config as CMake/Config
    participant Main as main.cpp
    participant Logger as LoggerWrapper
    participant User as Developer/User

    User->>Config: Set MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY (string)
    Config->>Main: Compile with macro MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY
    Main->>Logger: Logger::init(LOGGER_VERBOSITY)
    Logger->>Logger: Compile-time filter for log level
    Main->>Logger: Log messages
    Logger-->>Main: Filtered log output (at or above set verbosity)
Loading
sequenceDiagram
    participant ExternalClient
    participant DummyCommunication
    participant Settings

    ExternalClient->>Settings: Read protocol type
    alt protocol == DUMMY
        ExternalClient->>DummyCommunication: Create and initialize
        DummyCommunication->>ExternalClient: Provide dummy send/receive
    else protocol == MQTT
        ExternalClient->>MqttCommunication: Create and initialize
    end
Loading

Possibly related PRs

  • More logging options in configuration #38: The main PR introduces a compile-time configurable minimum logger verbosity level with related changes to logger wrappers and enum utilities, while the retrieved PR focuses on adding more logging options in configuration and related enum utilities; both modify logger verbosity handling and enum utility code, indicating a direct and strong connection in logging configuration and enum utility code.

Suggested reviewers

  • koudis

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7911f7c and bb7ca23.

📒 Files selected for processing (3)
  • include/bringauto/settings/LoggerId.hpp (1 hunks)
  • source/bringauto/settings/LoggerId.cpp (1 hunks)
  • test/source/InternalServerTests.cpp (20 hunks)
✅ Files skipped from review due to trivial changes (1)
  • source/bringauto/settings/LoggerId.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/source/InternalServerTests.cpp
  • include/bringauto/settings/LoggerId.hpp
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BAF-1122/optimizations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
include/bringauto/structures/AtomicQueue.hpp (1)

33-36: Clarify return-value semantics in the fresh comment while you’re here

Nice typo fix. Since you’re touching the docblock anyway, consider spelling out that the function returns true only when the timeout expired and the queue is still empty:

- * @return true if the queue is empty
+ * @return true if the queue is still empty after the timeout has elapsed,
+ *         false if a value became available before the timeout.
README.md (1)

80-88: LGTM! Clear documentation of new logger verbosity option.

The documentation clearly explains the new MINIMUM_LOGGER_VERBOSITY CMake option and its performance benefits through compile-time log filtering. This aligns well with the PR's performance optimization objectives.

Consider fixing the minor formatting inconsistency flagged by markdownlint - the list uses asterisks while other lists in the file use dashes.

-* MINIMUM_LOGGER_VERBOSITY=0/1/2/3/4
+- MINIMUM_LOGGER_VERBOSITY=0/1/2/3/4
source/bringauto/common_utils/EnumUtils.cpp (1)

13-15: DUMMY protocol support added correctly.

The logic for handling the DUMMY protocol type is consistent with the existing MQTT protocol handling. However, there's an indentation inconsistency - the new code uses spaces while the existing code appears to use tabs.

Consider fixing the indentation to match the existing style:

-	} else if(toEnum == settings::Constants::DUMMY) {
-        return structures::ProtocolType::DUMMY;
-    }
+	} else if(toEnum == settings::Constants::DUMMY) {
+		return structures::ProtocolType::DUMMY;
+	}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
README.md (2)

80-82: Markdown-lint MD004 violation – switch to dash bullets for consistency

markdownlint flags the new bullet because the project’s doc style-guide prefers - over *.
Since the surrounding list items (61-78) already use *, you can either:

  1. Adopt dashes here and everywhere else (preferred ‑ silences the linter globally), or
  2. Add an explicit rule override to keep asterisks.

Example fix for the new item:

-* MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=0/1/2/3/4
+- MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=0/1/2/3/4

83-88: Spell out the enum names to avoid “magic numbers”

Readers unfamiliar with ba-logger may not know which numeric level maps to which macro/enum.
Consider appending the symbolic names once to improve clarity:

-  - 0: DEBUG
-  - 1: INFO
-  - 2: WARNING
-  - 3: ERROR
-  - 4: CRITICAL
+  - 0 (`BA_LOGGER_VERBOSITY_DEBUG`): DEBUG  
+  - 1 (`BA_LOGGER_VERBOSITY_INFO`): INFO  
+  - 2 (`BA_LOGGER_VERBOSITY_WARNING`): WARNING  
+  - 3 (`BA_LOGGER_VERBOSITY_ERROR`): ERROR  
+  - 4 (`BA_LOGGER_VERBOSITY_CRITICAL`): CRITICAL

This keeps the README self-contained and reduces the mental jump to the codebase/macros.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf2f5e and b4bd01a.

📒 Files selected for processing (9)
  • CMakeLists.txt (1 hunks)
  • Dockerfile (1 hunks)
  • README.md (1 hunks)
  • include/bringauto/settings/LoggerId.hpp (1 hunks)
  • include/bringauto/settings/LoggerWrapper.hpp (1 hunks)
  • include/bringauto/structures/Connection.hpp (1 hunks)
  • main.cpp (3 hunks)
  • source/bringauto/common_utils/ProtobufUtils.cpp (5 hunks)
  • source/bringauto/internal_server/InternalServer.cpp (18 hunks)
🧠 Learnings (1)
README.md (6)

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-03T17:41:56.410Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-09T05:03:50.249Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-09-30T11:00:40.818Z
Learning: The bringauto_log module does not currently use the debug log level.

🪛 markdownlint-cli2 (0.17.2)
README.md

80-80: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

✅ Files skipped from review due to trivial changes (1)
  • Dockerfile
🚧 Files skipped from review as they are similar to previous changes (7)
  • include/bringauto/structures/Connection.hpp
  • main.cpp
  • source/bringauto/common_utils/ProtobufUtils.cpp
  • CMakeLists.txt
  • include/bringauto/settings/LoggerWrapper.hpp
  • include/bringauto/settings/LoggerId.hpp
  • source/bringauto/internal_server/InternalServer.cpp
🧰 Additional context used
🧠 Learnings (1)
README.md (6)

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-03T17:41:56.410Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-09T05:03:50.249Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-09-30T11:00:40.818Z
Learning: The bringauto_log module does not currently use the debug log level.

🪛 markdownlint-cli2 (0.17.2)
README.md

80-80: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
include/bringauto/settings/LoggerId.hpp (1)

34-45: Consider making the DEBUG case explicit.

The function correctly converts string verbosity levels to enum values. However, the "DEBUG" case is handled implicitly by the default return. Consider making it explicit for clarity:

 constexpr logging::LoggerVerbosity toLoggerVerbosity(std::string_view verbosityString) {
-	if (verbosityString == "INFO") {
+	if (verbosityString == "DEBUG") {
+		return logging::LoggerVerbosity::Debug;
+	} else if (verbosityString == "INFO") {
 		return logging::LoggerVerbosity::Info;
 	} else if (verbosityString == "WARNING") {
 		return logging::LoggerVerbosity::Warning;
 	} else if (verbosityString == "ERROR") {
 		return logging::LoggerVerbosity::Error;
 	} else if (verbosityString == "CRITICAL") {
 		return logging::LoggerVerbosity::Critical;
 	}
-	return logging::LoggerVerbosity::Debug;
+	// This should never be reached due to static_assert validation
+	return logging::LoggerVerbosity::Debug;
 }
README.md (1)

80-83: Good documentation of the new compile-time logging feature.

The documentation accurately describes the new MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY CMake argument and its performance benefits. The listed verbosity levels match the implementation.

Fix the list style for consistency with the rest of the document:

-* MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=DEBUG/INFO/WARNING/ERROR/CRITICAL
+- MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=DEBUG/INFO/WARNING/ERROR/CRITICAL
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4bd01a and 4a84ce1.

📒 Files selected for processing (4)
  • CMakeLists.txt (1 hunks)
  • README.md (1 hunks)
  • include/bringauto/external_client/connection/communication/DummyCommunication.hpp (1 hunks)
  • include/bringauto/settings/LoggerId.hpp (1 hunks)
🧠 Learnings (2)
include/bringauto/settings/LoggerId.hpp (5)

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:26-31
Timestamp: 2024-10-31T10:44:39.657Z
Learning: In the ModuleGateway project, logging settings are validated in SettingsParser, so additional validation in the LoggingSettings structure is not necessary.

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: Melky-Phoe
PR: bringauto/fleet-management-http-api#17
File: fleet_management_api/main.py:42-42
Timestamp: 2024-09-18T06:54:20.565Z
Learning: The team prefers using constants for configuration values like the logging configuration file path instead of making them configurable via command-line arguments or configuration parameters unless necessary.

Learnt from: Melky-Phoe
PR: bringauto/fleet-management-http-api#17
File: fleet_management_api/main.py:42-42
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The team prefers using constants for configuration values like the logging configuration file path instead of making them configurable via command-line arguments or configuration parameters unless necessary.

README.md (6)

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-09-30T11:00:40.818Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-03T17:41:56.410Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-09T05:03:50.249Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

🪛 markdownlint-cli2 (0.17.2)
README.md

80-80: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🚧 Files skipped from review as they are similar to previous changes (2)
  • CMakeLists.txt
  • include/bringauto/external_client/connection/communication/DummyCommunication.hpp
🧰 Additional context used
🧠 Learnings (2)
include/bringauto/settings/LoggerId.hpp (5)

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:26-31
Timestamp: 2024-10-31T10:44:39.657Z
Learning: In the ModuleGateway project, logging settings are validated in SettingsParser, so additional validation in the LoggingSettings structure is not necessary.

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: Melky-Phoe
PR: bringauto/fleet-management-http-api#17
File: fleet_management_api/main.py:42-42
Timestamp: 2024-09-18T06:54:20.565Z
Learning: The team prefers using constants for configuration values like the logging configuration file path instead of making them configurable via command-line arguments or configuration parameters unless necessary.

Learnt from: Melky-Phoe
PR: bringauto/fleet-management-http-api#17
File: fleet_management_api/main.py:42-42
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The team prefers using constants for configuration values like the logging configuration file path instead of making them configurable via command-line arguments or configuration parameters unless necessary.

README.md (6)

Learnt from: koudis
PR: #43
File: CMakeLists.txt:11-14
Timestamp: 2025-06-29T18:12:34.666Z
Learning: In the ModuleGateway project's CMakeLists.txt, compile definitions for version strings are intentionally set with escaped quotes using CMDEF_COMPILE_DEFINITIONS to produce compiler flags like -DMODULE_GATEWAY_VERSION="1.3.3", ensuring the macro expands to a proper string literal in C++ code.

Learnt from: MarioIvancik
PR: #38
File: include/bringauto/structures/LoggingSettings.hpp:10-15
Timestamp: 2024-10-31T10:45:48.494Z
Learning: In the ModuleGateway project, values in the structures defined in include/bringauto/structures/LoggingSettings.hpp are validated in SettingsParser.cpp, so additional validation within the structures is unnecessary.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-10-09T05:03:50.249Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: mikusaq
PR: bacpack-system/packager#24
File: modules/bringauto_log/Handler.go:40-54
Timestamp: 2024-09-30T11:00:40.818Z
Learning: The bringauto_log module does not currently use the debug log level.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-03T17:41:56.410Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

Learnt from: Mayt34
PR: bringauto/transparent-module#1
File: CMakeLists.txt:15-20
Timestamp: 2024-10-09T05:03:50.249Z
Learning: In the transparent_module project, all modules should be built by default; FLEET_PROTOCOL_BUILD_MODULE_GATEWAY and FLEET_PROTOCOL_BUILD_EXTERNAL_SERVER should be set to ON by default.

🪛 markdownlint-cli2 (0.17.2)
README.md

80-80: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (4)
include/bringauto/settings/LoggerId.hpp (4)

3-7: LGTM: Clean macro definition with proper default.

The include and macro definition are well-structured. The conditional definition allows CMake to override the default while providing a sensible fallback.


19-21: Well-implemented constexpr string comparison.

The use of std::string_view for compile-time string comparison is efficient and appropriate. This enables the static_assert validation at compile time.


23-28: Excellent compile-time validation.

The static_assert provides robust validation of the verbosity level macro at compile time, preventing invalid configurations from compiling. This addresses potential runtime errors early in the build process.


47-50: Excellent design for compile-time logging optimization.

The type aliases create a clean abstraction that enables compile-time log filtering. The Logger alias uses LoggerWrapper with compile-time verbosity evaluation, which should provide the performance benefits mentioned in the PR objectives.

@sonarqubecloud
Copy link

if (!socket.is_open()) {
return "(N/A, socket is not open)";
}
return socket.remote_endpoint().address().to_string();
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure this will always work and does not omit exceptions?

INVALID = -1,
MQTT
MQTT,
DUMMY
Copy link
Member

Choose a reason for hiding this comment

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

Documentation for each Enum element?

connectMessage->set_company(company);
connectMessage->set_vehiclename(vehicleName);

connectMessage->mutable_devices()->Reserve(devices.size());
Copy link
Member

Choose a reason for hiding this comment

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

Why reverse?

return;
}
else if (client_ != nullptr) {
if (client_ != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

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

Why was the "else" deleted? Oo, I see if it is connected I want to close the connection in this case.

return connection->deviceId->isSame(toCompare->deviceId);
});
const auto it = std::find_if(connectedDevices_.begin(), connectedDevices_.end(),
[&connection](const std::shared_ptr<structures::Connection> &toCompare) {
Copy link
Member

Choose a reason for hiding this comment

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

Indent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants