-
Notifications
You must be signed in to change notification settings - Fork 0
Baf 1155/use async client #47
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
Open
koudis
wants to merge
16
commits into
BAF-1122/optimizations
Choose a base branch
from
BAF-1155/use_async_client
base: BAF-1122/optimizations
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
22ce960
added aeron classes for initial testing
MarioIvancik be654fe
check returned messages from aeron client
MarioIvancik 6832376
functional aeron module communication
MarioIvancik 7ff00e3
added docstrings for AeronClient
MarioIvancik fec0353
async function execution usage
MarioIvancik b0834cb
async client as a package
MarioIvancik 0c31aca
refactor of module library handler
MarioIvancik e87960a
Set correct system name
koudis e18d1f7
added mutexes for async client; use filesystem::path for file paths
MarioIvancik f5c0f4c
removed memory management; added module based channel offset
MarioIvancik 19e7613
added error handling to async module
MarioIvancik 0be5cfd
use function definitions from fleet protocol cpp
MarioIvancik 3a70050
Check if module defined in external-connection endpoint exists in mod…
vrygl e02cf04
dont ignore nodiscard value in std::ranged::any_of
vrygl e8fe4b7
Added missing param in logWarning
vrygl 8823278
Merge pull request #48 from bringauto/BAF-1250/gateway_crashes_when_e…
koudis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| FIND_PACKAGE(CMLIB REQUIRED COMPONENTS CMCONF) | ||
|
|
||
| CMCONF_INIT_SYSTEM(FLEET_PROTOCOL) | ||
|
|
||
| SET(STORAGE_LIST DEP) | ||
|
|
||
| SET(STORAGE_LIST_DEP "https://github.com/bacpack-system/package-tracker.git") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
include/bringauto/modules/IModuleManagerLibraryHandler.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #pragma once | ||
|
|
||
| #include <bringauto/modules/Buffer.hpp> | ||
|
|
||
| #include <filesystem> | ||
|
|
||
|
|
||
|
|
||
| namespace bringauto::modules { | ||
|
|
||
| /** | ||
| * @brief Class used to load and handle library created by module maintainer | ||
| */ | ||
| class IModuleManagerLibraryHandler { | ||
| public: | ||
| explicit IModuleManagerLibraryHandler() = default; | ||
|
|
||
| virtual ~IModuleManagerLibraryHandler() = default; | ||
|
|
||
| /** | ||
| * @brief Load library created by a module maintainer | ||
| * | ||
| * @param path path to the library | ||
| */ | ||
| virtual void loadLibrary(const std::filesystem::path &path) = 0; | ||
|
|
||
| virtual int getModuleNumber() = 0; | ||
|
|
||
| virtual int isDeviceTypeSupported(unsigned int device_type) = 0; | ||
|
|
||
| virtual int sendStatusCondition(const Buffer ¤t_status, const Buffer &new_status, unsigned int device_type) = 0; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| virtual int generateCommand(Buffer &generated_command, const Buffer &new_status, | ||
| const Buffer ¤t_status, const Buffer ¤t_command, | ||
| unsigned int device_type) = 0; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| virtual int aggregateStatus(Buffer &aggregated_status, const Buffer ¤t_status, | ||
| const Buffer &new_status, unsigned int device_type) = 0; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| virtual int aggregateError(Buffer &error_message, const Buffer ¤t_error_message, const Buffer &status, | ||
| unsigned int device_type) = 0; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| virtual int generateFirstCommand(Buffer &default_command, unsigned int device_type) = 0; | ||
|
|
||
| virtual int statusDataValid(const Buffer &status, unsigned int device_type) = 0; | ||
|
|
||
| virtual int commandDataValid(const Buffer &command, unsigned int device_type) = 0; | ||
|
|
||
| /** | ||
| * @brief Constructs a buffer with the given size | ||
| * | ||
| * @param size size of the buffer | ||
| * @return a new Buffer object | ||
| */ | ||
| virtual Buffer constructBuffer(std::size_t size = 0) = 0; | ||
| }; | ||
|
|
||
| } | ||
123 changes: 123 additions & 0 deletions
123
include/bringauto/modules/ModuleManagerLibraryHandlerAsync.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #pragma once | ||
|
|
||
| #include <bringauto/modules/IModuleManagerLibraryHandler.hpp> | ||
| #include <bringauto/settings/Constants.hpp> | ||
|
|
||
| #include <bringauto/async_function_execution/AsyncFunctionExecutor.hpp> | ||
| #include <bringauto/fleet_protocol/cxx/AsyncModuleFunctionDefinitions.hpp> | ||
| #include <boost/process.hpp> | ||
|
|
||
| #include <mutex> | ||
|
|
||
|
|
||
|
|
||
| namespace bringauto::modules { | ||
|
|
||
| /** | ||
| * @brief Class used to load and handle library created by module maintainer | ||
| */ | ||
| class ModuleManagerLibraryHandlerAsync : public IModuleManagerLibraryHandler { | ||
| public: | ||
| explicit ModuleManagerLibraryHandlerAsync(const std::filesystem::path &moduleBinaryPath, const int moduleNumber); | ||
|
|
||
| ~ModuleManagerLibraryHandlerAsync() override; | ||
|
|
||
| /** | ||
| * @brief Load library created by a module maintainer | ||
| * | ||
| * @param path path to the library | ||
| */ | ||
| void loadLibrary(const std::filesystem::path &path) override; | ||
|
|
||
| int getModuleNumber() override; | ||
|
|
||
| int isDeviceTypeSupported(unsigned int device_type) override; | ||
|
|
||
| int sendStatusCondition(const Buffer ¤t_status, const Buffer &new_status, unsigned int device_type) override; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| int generateCommand(Buffer &generated_command, const Buffer &new_status, | ||
| const Buffer ¤t_status, const Buffer ¤t_command, | ||
| unsigned int device_type) override; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| int aggregateStatus(Buffer &aggregated_status, const Buffer ¤t_status, | ||
| const Buffer &new_status, unsigned int device_type) override; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| int aggregateError(Buffer &error_message, const Buffer ¤t_error_message, const Buffer &status, | ||
| unsigned int device_type) override; | ||
|
|
||
| /** | ||
| * @short After executing the respective module function, an error might be thrown when allocating the buffer. | ||
| * | ||
| * @see fleet-protocol/lib/module_maintainer/module_gateway/include/module_manager.h | ||
| */ | ||
| int generateFirstCommand(Buffer &default_command, unsigned int device_type) override; | ||
|
|
||
| int statusDataValid(const Buffer &status, unsigned int device_type) override; | ||
|
|
||
| int commandDataValid(const Buffer &command, unsigned int device_type) override; | ||
|
|
||
| /** | ||
| * @brief Constructs a buffer with the given size | ||
| * | ||
| * @param size size of the buffer | ||
| * @return a new Buffer object | ||
| */ | ||
| Buffer constructBuffer(std::size_t size = 0) override; | ||
|
|
||
| private: | ||
|
|
||
| int allocate(struct buffer *buffer_pointer, size_t size_in_bytes) const; | ||
|
|
||
| void deallocate(struct buffer *buffer) const; | ||
|
|
||
| /** | ||
| * @brief Constructs a buffer with the same raw c buffer as provided | ||
| * | ||
| * @param buffer c buffer to be used | ||
| * @return a new Buffer object | ||
| */ | ||
| Buffer constructBufferByTakeOwnership(struct ::buffer& buffer); | ||
|
|
||
| std::function<void(struct buffer *)> deallocate_ {}; | ||
|
|
||
| /// Path to the module binary | ||
| std::filesystem::path moduleBinaryPath_ {}; | ||
| /// Process of the module binary | ||
| boost::process::child moduleBinaryProcess_ {}; | ||
|
|
||
| /// TODO find a way to not need this | ||
| std::mutex getModuleNumberMutex_ {}; | ||
| std::mutex isDeviceTypeSupportedMutex_ {}; | ||
| std::mutex sendStatusConditionMutex_ {}; | ||
| std::mutex generateCommandMutex_ {}; | ||
| std::mutex aggregateStatusMutex_ {}; | ||
| std::mutex aggregateErrorMutex_ {}; | ||
| std::mutex generateFirstCommandMutex_ {}; | ||
| std::mutex statusDataValidMutex_ {}; | ||
| std::mutex commandDataValidMutex_ {}; | ||
|
|
||
| fleet_protocol::cxx::ModuleFunctionExecutor aeronClient { | ||
| async_function_execution::Config { | ||
| .isProducer = true, | ||
| .defaultTimeout = settings::AeronClientConstants::aeron_client_default_timeout, | ||
| }, | ||
| fleet_protocol::cxx::moduleFunctionList | ||
| }; | ||
| }; | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why for some functions the documentation is missing?