-
Notifications
You must be signed in to change notification settings - Fork 0
Performance/networking optimizations #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
26ec6fb
ad56409
bdf7b21
74db3ea
81b3e80
31746e5
7e9d3ad
43ed3c7
115f620
ecef0e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,9 +20,9 @@ namespace bringauto::external_client { | |||||||||||
| class ExternalClient { | ||||||||||||
| public: | ||||||||||||
|
|
||||||||||||
| ExternalClient(std::shared_ptr<structures::GlobalContext> &context, | ||||||||||||
| ExternalClient(const std::shared_ptr<structures::GlobalContext> &context, | ||||||||||||
| structures::ModuleLibrary &moduleLibrary, | ||||||||||||
| std::shared_ptr<structures::AtomicQueue<structures::InternalClientMessage>> &toExternalQueue); | ||||||||||||
| const std::shared_ptr<structures::AtomicQueue<structures::InternalClientMessage>> &toExternalQueue); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Initialize connections, error aggregators | ||||||||||||
|
|
@@ -54,7 +54,7 @@ class ExternalClient { | |||||||||||
| void handleAggregatedMessages(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Handle commands messages from from an external server | ||||||||||||
| * @brief Handle commands messages from an external server | ||||||||||||
| */ | ||||||||||||
| void handleCommands(); | ||||||||||||
|
|
||||||||||||
|
|
@@ -68,18 +68,18 @@ class ExternalClient { | |||||||||||
| /** | ||||||||||||
| * @brief Send aggregated status message to the external server | ||||||||||||
| * | ||||||||||||
| * @param deviceStatus aggregated status message ready to send | ||||||||||||
| * @param internalMessage aggregated status message ready to send | ||||||||||||
| * @return reconnect expected if true, reconnect not expected if false | ||||||||||||
| */ | ||||||||||||
| bool sendStatus(const structures::InternalClientMessage &deviceStatus); | ||||||||||||
| bool sendStatus(const structures::InternalClientMessage &internalMessage); | ||||||||||||
|
|
||||||||||||
| bool insideConnectSequence_ { false }; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Map of external connections, key is number from settings | ||||||||||||
| * - map is needed because of the possibility of multiple modules connected to one external server | ||||||||||||
| */ | ||||||||||||
| std::map<unsigned int, std::reference_wrapper<connection::ExternalConnection>> externalConnectionMap_ {}; | ||||||||||||
| std::unordered_map<unsigned int, std::reference_wrapper<connection::ExternalConnection>> externalConnectionMap_ {}; | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find and examine ExternalClient.hpp
echo "=== ExternalClient.hpp location ==="
fd 'ExternalClient\.hpp$'
echo ""
echo "=== Current includes in ExternalClient.hpp ==="
fd 'ExternalClient\.hpp$' -x cat -n {} | head -30
echo ""
echo "=== Check for unordered_map around line 82 ==="
fd 'ExternalClient\.hpp$' -x sed -n '75,90p' {}Repository: bringauto/module-gateway Length of output: 2267 🏁 Script executed: #!/bin/bash
# Check ExternalConnection.hpp for unordered_map
echo "=== ExternalConnection.hpp location ==="
fd 'ExternalConnection\.hpp$'
echo ""
echo "=== Check if unordered_map is in ExternalConnection.hpp ==="
fd 'ExternalConnection\.hpp$' -x rg -n 'unordered_map|#include.*unordered' {}Repository: bringauto/module-gateway Length of output: 313 🏁 Script executed: #!/bin/bash
# Check if ExternalConnection.hpp includes unordered_map
echo "=== First 30 lines of ExternalConnection.hpp ==="
fd 'ExternalConnection\.hpp$' -x head -30 {}Repository: bringauto/module-gateway Length of output: 1377 🏁 Script executed: #!/bin/bash
# Check all includes in ExternalConnection.hpp
echo "=== All includes in ExternalConnection.hpp ==="
fd 'ExternalConnection\.hpp$' -x sed -n '1,20p' {}Repository: bringauto/module-gateway Length of output: 854 🏁 Script executed: #!/bin/bash
# Check ErrorAggregator.hpp since it's used as value type in ExternalConnection's unordered_map
echo "=== ErrorAggregator.hpp includes (first 30 lines) ==="
fd 'ErrorAggregator\.hpp$' -x head -30 {}Repository: bringauto/module-gateway Length of output: 842 Add missing
Suggested fix `#include` <memory>
`#include` <vector>
`#include` <list>
+#include <unordered_map>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| /// List of external connections, each device can have its own connection or multiple devices can share one connection | ||||||||||||
| std::list<connection::ExternalConnection> externalConnectionsList_ {}; | ||||||||||||
| /// Queue for messages from module handler to external client to be sent to external server | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include <bringauto/external_client/connection/communication/ICommunicationChannel.hpp> | ||
|
|
||
|
|
||
|
|
||
| namespace bringauto::external_client::connection::communication { | ||
|
|
||
| /** | ||
| * @brief Dummy communication channel for unit-test and send-only scenarios. | ||
| * Does not establish any real connection, just simulates it. | ||
| * | ||
| * Constraints: | ||
| * - receiveMessage() always returns nullptr. | ||
| * - Because ExternalConnection's connect sequence relies on receiving a valid | ||
| * server response, DUMMY can never complete a connect sequence. Any gateway | ||
| * instance configured with protocol-type "DUMMY" will loop reconnecting | ||
| * indefinitely. Use only in unit tests or when the connect sequence is | ||
| * bypassed by the test harness. | ||
| * - initializeConnection() and closeConnection() only toggle an internal flag | ||
| * used to gate sendMessage() log output. | ||
| */ | ||
| class DummyCommunication: public ICommunicationChannel { | ||
MarioIvancik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public: | ||
| explicit DummyCommunication(const structures::ExternalConnectionSettings &settings); | ||
|
|
||
| ~DummyCommunication() override; | ||
|
|
||
| void initializeConnection() override; | ||
|
|
||
| bool sendMessage(ExternalProtocol::ExternalClient *message) override; | ||
|
|
||
| std::shared_ptr<ExternalProtocol::ExternalServer> receiveMessage() override; | ||
|
|
||
| void closeConnection() override; | ||
|
|
||
| private: | ||
| /// Flag to indicate if the fake connection is established | ||
| bool isConnected_ { false }; | ||
| }; | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.