feat: Allow custom RPC names for some plugins (#33)
* Allow custom RPC names for some plugins
This commit is contained in:
parent
5b85a23678
commit
fabac84bb0
@ -16,3 +16,5 @@
|
||||
- 升级 jsoncpp 至 1.9.6 版本以优化一些 cmake 问题;
|
||||
- 新增了 aimrt_py channel benchmark 示例;
|
||||
- iceoryx 插件在编译前先检查是否存在libacl,不存在则不进行编译;
|
||||
- 提供 RPC 服务的插件现在支持指定 service name;
|
||||
|
||||
|
@ -17,8 +17,11 @@
|
||||
**log_control_plugin**中注册了一个基于 protobuf 协议定义的 RPC,提供了针对 Log 的一些运行时管理接口。请注意,**log_control_plugin**没有提供任何通信后端,因此本插件一般要搭配其他通信插件的 RPC 后端一块使用,例如[net_plugin](./net_plugin.md)中的 http RPC 后端。
|
||||
|
||||
|
||||
插件的配置项如下:
|
||||
|
||||
在当前版本,本插件没有插件级的配置。
|
||||
| 节点 | 类型 | 是否可选| 默认值 | 作用 |
|
||||
| ---- | ---- | ---- | ---- | ---- |
|
||||
| service_name | string | 可选 | "" | RPC Service Name,不填则使用根据协议生成的默认值 |
|
||||
|
||||
|
||||
以下是一个简单的配置示例,将**log_control_plugin**与**net_plugin**中的 http RPC 后端搭配使用:
|
||||
|
@ -14,8 +14,15 @@
|
||||
|
||||
**parameter_plugin**中注册了一个基于 protobuf 协议定义的 RPC,提供了针对 Parameter 的一些管理接口。请注意,**parameter_plugin**没有提供任何通信后端,因此本插件一般要搭配其他通信插件的 RPC 后端一块使用,例如[net_plugin](./net_plugin.md)中的 http RPC 后端。
|
||||
|
||||
插件的配置项如下:
|
||||
|
||||
| 节点 | 类型 | 是否可选| 默认值 | 作用 |
|
||||
| ---- | ---- | ---- | ---- | ---- |
|
||||
| service_name | string | 可选 | "" | RPC Service Name,不填则使用根据协议生成的默认值 |
|
||||
|
||||
|
||||
以下是一个简单的配置示例,将**parameter_plugin**与**net_plugin**中的 http RPC 后端搭配使用:
|
||||
|
||||
在当前版本,本插件没有插件级的配置。以下是一个简单的配置示例,将**parameter_plugin**与**net_plugin**中的 http RPC 后端搭配使用:
|
||||
|
||||
```yaml
|
||||
aimrt:
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
| 节点 | 类型 | 是否可选| 默认值 | 作用 |
|
||||
| ---- | ---- | ---- | ---- | ---- |
|
||||
| service_name | string | 可选 | "" | RPC Service Name,不填则使用根据协议生成的默认值 |
|
||||
| type_support_pkgs | array | 可选 | [] | type support 包配置 |
|
||||
| type_support_pkgs[i].path | string | 必选 | "" | type support 包的路径 |
|
||||
| record_actions | array | 可选 | [] | 录制动作配置 |
|
||||
@ -71,7 +72,7 @@ aimrt:
|
||||
path: ./libaimrt_record_playback_plugin.so
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./libexample_event_type_support_pkg.so
|
||||
- path: ./libexample_event_ts_pkg.so
|
||||
record_actions:
|
||||
- name: my_signal_record
|
||||
options:
|
||||
|
@ -15,8 +15,14 @@
|
||||
|
||||
**time_manipulator_plugin**中提供了`time_manipulator`执行器,可以实现时间调速功能。同时注册了一个基于 protobuf 协议定义的 RPC,提供了对于`time_manipulator`执行器的一些管理接口。请注意,**time_manipulator_plugin**没有提供任何通信后端,因此本插件一般要搭配其他通信插件的 RPC 后端一块使用,例如[net_plugin](./net_plugin.md)中的 http RPC 后端。
|
||||
|
||||
插件的配置项如下:
|
||||
|
||||
在当前版本,本插件没有插件级的配置。以下是一个简单的配置示例,将**time_manipulator_plugin**与**net_plugin**中的 http RPC 后端搭配使用:
|
||||
| 节点 | 类型 | 是否可选| 默认值 | 作用 |
|
||||
| ---- | ---- | ---- | ---- | ---- |
|
||||
| service_name | string | 可选 | "" | RPC Service Name,不填则使用根据协议生成的默认值 |
|
||||
|
||||
|
||||
以下是一个简单的配置示例,将**time_manipulator_plugin**与**net_plugin**中的 http RPC 后端搭配使用:
|
||||
|
||||
```yaml
|
||||
aimrt:
|
||||
|
@ -8,7 +8,7 @@ string(REGEX REPLACE ".*/\(.*\)" "\\1" CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_namespace()
|
||||
|
||||
# type_support_pkg
|
||||
add_subdirectory(example_event_type_support_pkg)
|
||||
add_subdirectory(example_event_ts_pkg)
|
||||
|
||||
# install
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
@ -12,7 +12,7 @@
|
||||
- [event.proto](../../../protocols/example/event.proto)
|
||||
- [normal_publisher_module.cc](../../cpp/pb_chn/module/normal_publisher_module/normal_publisher_module.cc)
|
||||
- [normal_subscriber_module.cc](../../cpp/pb_chn/module/normal_subscriber_module/normal_subscriber_module.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_type_support_pkg/type_support_pkg_main.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_ts_pkg/type_support_pkg_main.cc)
|
||||
|
||||
|
||||
配置文件:
|
||||
@ -30,7 +30,7 @@
|
||||
- 此示例创建了以下两个模块:
|
||||
- `NormalPublisherModule`:会基于 `work_thread_pool` 执行器,以配置的频率、向配置的 topic 中发布 `ExampleEventMsg` 类型的消息;
|
||||
- `NormalSubscriberModule`:会订阅配置的 topic 下的 `ExampleEventMsg` 类型的消息;
|
||||
- 此示例加载了 `example_event_type_support_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为录包时的序列化工具;
|
||||
- 此示例加载了 `example_event_ts_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为录包时的序列化工具;
|
||||
- 此示例创建了一个 `my_imd_record` 的录包 action,会在进程启动时立即开始录制指定的 topic 下的 msg,录制下来的包存放在进程同目录下的 `bag` 路径下;
|
||||
- 请注意,录包的原理是向 AimRT 订阅指定的 Topic,因此需要在 channel 配置中为该 topic 设置合适的后端,以保证录包插件能接收到数据;
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
- [event.proto](../../../protocols/example/event.proto)
|
||||
- [normal_publisher_module.cc](../../cpp/pb_chn/module/normal_publisher_module/normal_publisher_module.cc)
|
||||
- [normal_subscriber_module.cc](../../cpp/pb_chn/module/normal_subscriber_module/normal_subscriber_module.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_type_support_pkg/type_support_pkg_main.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_ts_pkg/type_support_pkg_main.cc)
|
||||
|
||||
|
||||
配置文件:
|
||||
@ -70,7 +70,7 @@
|
||||
- 此示例创建了以下两个模块:
|
||||
- `NormalPublisherModule`:会基于 `work_thread_pool` 执行器,以配置的频率、向配置的 topic 中发布 `ExampleEventMsg` 类型的消息;
|
||||
- `NormalSubscriberModule`:会订阅配置的 topic 下的 `ExampleEventMsg` 类型的消息;
|
||||
- 此示例加载了 `example_event_type_support_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为录包时的序列化工具;
|
||||
- 此示例加载了 `example_event_ts_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为录包时的序列化工具;
|
||||
- 此示例创建了一个 `my_signal_record` 的录包 action,会在接收到开始录制的 rpc 请求后录制指定的 topic 下的 msg,在接收到停止录制的 rpc 请求后结束录制,录制下来的包存放在进程同目录下的 `bag` 路径下;
|
||||
- 请注意,录包的原理是向 AimRT 订阅指定的 Topic,因此需要在 channel 配置中为该 topic 设置合适的后端,以保证录包插件能接收到数据;
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
核心代码:
|
||||
- [event.proto](../../../protocols/example/event.proto)
|
||||
- [normal_subscriber_module.cc](../../cpp/pb_chn/module/normal_subscriber_module/normal_subscriber_module.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_type_support_pkg/type_support_pkg_main.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_ts_pkg/type_support_pkg_main.cc)
|
||||
|
||||
|
||||
配置文件:
|
||||
@ -103,7 +103,7 @@
|
||||
|
||||
说明:
|
||||
- 此示例创建了 `NormalSubscriberModule`,会订阅配置的 topic 下的 `ExampleEventMsg` 类型的消息;
|
||||
- 此示例加载了 `example_event_type_support_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为播放时的反序列化工具;
|
||||
- 此示例加载了 `example_event_ts_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为播放时的反序列化工具;
|
||||
- 此示例创建了一个 `my_imd_playback` 的播包 action,会在进程启动时加载数据包,并立即开始播放其中指定的 topic 下的 msg;
|
||||
- 请注意,播包的原理是向 AimRT 发布指定的 Topic,因此需要在 channel 配置中为该 topic 设置合适的后端,以保证数据能够通过指定的后端发布出去;
|
||||
|
||||
@ -122,7 +122,7 @@
|
||||
核心代码:
|
||||
- [event.proto](../../../protocols/example/event.proto)
|
||||
- [normal_subscriber_module.cc](../../cpp/pb_chn/module/normal_subscriber_module/normal_subscriber_module.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_type_support_pkg/type_support_pkg_main.cc)
|
||||
- [type_support_pkg_main.cc](./example_event_ts_pkg/type_support_pkg_main.cc)
|
||||
|
||||
|
||||
配置文件:
|
||||
@ -142,7 +142,7 @@
|
||||
|
||||
说明:
|
||||
- 此示例创建了 `NormalSubscriberModule`,会订阅配置的 topic 下的 `ExampleEventMsg` 类型的消息;
|
||||
- 此示例加载了 `example_event_type_support_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为播放时的反序列化工具;
|
||||
- 此示例加载了 `example_event_ts_pkg`,其中提供了 `ExampleEventMsg` 类型的 type support 工具,作为播放时的反序列化工具;
|
||||
- 此示例创建了一个 `my_signal_playback` 的播包 action,会在进程启动时加载数据包,并在接收到开始播放的 rpc 请求后播放指定的 topic 下的 msg,在接收到停止播放的 rpc 请求后结束播放,
|
||||
- 请注意,播包的原理是向 AimRT 发布指定的 Topic,因此需要在 channel 配置中为该 topic 设置合适的后端,以保证数据能够通过指定的后端发布出去;
|
||||
|
||||
|
@ -8,7 +8,7 @@ aimrt:
|
||||
path: ./libaimrt_record_playback_plugin.so
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./libexample_event_type_support_pkg.so
|
||||
- path: ./libexample_event_ts_pkg.so
|
||||
playback_actions:
|
||||
- name: my_imd_playback
|
||||
options:
|
||||
|
@ -15,7 +15,7 @@ aimrt:
|
||||
path: ./libaimrt_record_playback_plugin.so
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./libexample_event_type_support_pkg.so
|
||||
- path: ./libexample_event_ts_pkg.so
|
||||
playback_actions:
|
||||
- name: my_signal_playback
|
||||
options:
|
||||
|
@ -8,7 +8,7 @@ aimrt:
|
||||
path: ./libaimrt_record_playback_plugin.so
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./libexample_event_type_support_pkg.so
|
||||
- path: ./libexample_event_ts_pkg.so
|
||||
record_actions:
|
||||
- name: my_imd_record
|
||||
options:
|
||||
|
@ -15,7 +15,7 @@ aimrt:
|
||||
path: ./libaimrt_record_playback_plugin.so
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./libexample_event_type_support_pkg.so
|
||||
- path: ./libexample_event_ts_pkg.so
|
||||
record_actions:
|
||||
- name: my_signal_record
|
||||
options:
|
||||
|
@ -8,7 +8,7 @@ aimrt:
|
||||
path: ./aimrt_record_playback_plugin.dll
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./example_event_type_support_pkg.dll
|
||||
- path: ./example_event_ts_pkg.dll
|
||||
playback_actions:
|
||||
- name: my_imd_playback
|
||||
options:
|
||||
|
@ -15,7 +15,7 @@ aimrt:
|
||||
path: ./aimrt_record_playback_plugin.dll
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./example_event_type_support_pkg.dll
|
||||
- path: ./example_event_ts_pkg.dll
|
||||
playback_actions:
|
||||
- name: my_signal_playback
|
||||
options:
|
||||
|
@ -8,7 +8,7 @@ aimrt:
|
||||
path: ./aimrt_record_playback_plugin.dll
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./example_event_type_support_pkg.dll
|
||||
- path: ./example_event_ts_pkg.dll
|
||||
record_actions:
|
||||
- name: my_imd_record
|
||||
options:
|
||||
|
@ -15,7 +15,7 @@ aimrt:
|
||||
path: ./aimrt_record_playback_plugin.dll
|
||||
options:
|
||||
type_support_pkgs:
|
||||
- path: ./example_event_type_support_pkg.dll
|
||||
- path: ./example_event_ts_pkg.dll
|
||||
record_actions:
|
||||
- name: my_signal_record
|
||||
options:
|
||||
|
@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "aimrt_module_c_interface/core_base.h"
|
||||
#include "aimrt_module_c_interface/util/string.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
@ -11,7 +10,6 @@
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "util/exception.h"
|
||||
#include "util/string_util.h"
|
||||
#include "util/time_util.h"
|
||||
|
||||
namespace aimrt::channel {
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
|
||||
#include "aimrt_module_c_interface/executor/executor_base.h"
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "aimrt_module_c_interface/executor/executor_manager_base.h"
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "aimrt_module_c_interface/parameter/parameter_handle_base.h"
|
||||
#include "aimrt_module_cpp_interface/util/function.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
|
@ -4,18 +4,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "aimrt_module_c_interface/rpc/rpc_context_base.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "util/exception.h"
|
||||
#include "util/stl_tool.h"
|
||||
#include "util/string_util.h"
|
||||
#include "util/time_util.h"
|
||||
|
||||
namespace aimrt::rpc {
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "aimrt_module_c_interface/rpc/rpc_handle_base.h"
|
||||
#include "aimrt_module_cpp_interface/rpc/rpc_co_filter.h"
|
||||
@ -113,6 +112,7 @@ class RpcHandleRef {
|
||||
*/
|
||||
bool RegisterService(ServiceBase* service_ptr) {
|
||||
AIMRT_ASSERT(base_ptr_, "Reference is null.");
|
||||
AIMRT_ASSERT(service_ptr, "Service pointer is null.");
|
||||
|
||||
bool ret = true;
|
||||
|
||||
@ -132,6 +132,21 @@ class RpcHandleRef {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register service with specific name
|
||||
*
|
||||
* @param service_name
|
||||
* @param service_ptr
|
||||
* @return Register result
|
||||
*/
|
||||
bool RegisterService(std::string_view service_name, ServiceBase* service_ptr) {
|
||||
AIMRT_ASSERT(service_ptr, "Service pointer is null.");
|
||||
|
||||
service_ptr->SetServiceName(service_name);
|
||||
|
||||
return RegisterService(service_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register client func
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "aimrt_module_c_interface/util/buffer_base.h"
|
||||
#include "aimrt_module_cpp_interface/util/simple_buffer_array_allocator.h"
|
||||
#include "util/exception.h"
|
||||
|
||||
namespace aimrt::util {
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
|
@ -118,6 +118,8 @@ bool GrpcPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcept {
|
||||
});
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
|
@ -50,6 +50,7 @@ bool IceoryxPlugin::Initialize(runtime::core::AimRTCore *core_ptr) noexcept {
|
||||
[this] { RegisterIceoryxChannelBackend(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -15,12 +15,17 @@ struct convert<aimrt::plugins::log_control_plugin::LogControlPlugin::Options> {
|
||||
static Node encode(const Options& rhs) {
|
||||
Node node;
|
||||
|
||||
node["service_name"] = rhs.service_name;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, Options& rhs) {
|
||||
if (!node.IsMap()) return false;
|
||||
|
||||
if (node["service_name"])
|
||||
rhs.service_name = node["service_name"].as<std::string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -47,6 +52,8 @@ bool LogControlPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcept {
|
||||
[this] { RegisterRpcService(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
@ -70,9 +77,11 @@ void LogControlPlugin::SetPluginLogger() {
|
||||
}
|
||||
|
||||
void LogControlPlugin::RegisterRpcService() {
|
||||
// 注册rpc服务
|
||||
service_ptr_ = std::make_unique<LogControlServiceImpl>();
|
||||
|
||||
if (!options_.service_name.empty())
|
||||
service_ptr_->SetServiceName(options_.service_name);
|
||||
|
||||
service_ptr_->SetLoggerManager(&(core_ptr_->GetLoggerManager()));
|
||||
|
||||
auto rpc_handle_ref = aimrt::rpc::RpcHandleRef(
|
||||
|
@ -12,7 +12,9 @@ namespace aimrt::plugins::log_control_plugin {
|
||||
|
||||
class LogControlPlugin : public AimRTCorePluginBase {
|
||||
public:
|
||||
struct Options {};
|
||||
struct Options {
|
||||
std::string service_name;
|
||||
};
|
||||
|
||||
public:
|
||||
LogControlPlugin() = default;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// All rights reserved.
|
||||
|
||||
#include "log_control_plugin/service.h"
|
||||
#include "aimrt_module_protobuf_interface/util/protobuf_tools.h"
|
||||
#include "core/logger/log_level_tool.h"
|
||||
#include "log_control_plugin/global.h"
|
||||
|
||||
namespace aimrt::plugins::log_control_plugin {
|
||||
|
@ -120,6 +120,8 @@ bool MqttPlugin::Initialize(runtime::core::AimRTCore *core_ptr) noexcept {
|
||||
[this] { RegisterMqttChannelBackend(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception &e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <regex>
|
||||
|
||||
#include "aimrt_module_cpp_interface/rpc/rpc_status.h"
|
||||
#include "aimrt_module_cpp_interface/util/buffer.h"
|
||||
#include "aimrt_module_cpp_interface/util/type_support.h"
|
||||
#include "core/rpc/rpc_backend_tools.h"
|
||||
#include "mqtt_plugin/global.h"
|
||||
@ -531,6 +530,7 @@ void MqttRpcBackend::Invoke(
|
||||
size_t req_size = buffer_array_view_ptr->BufferSize();
|
||||
|
||||
// context
|
||||
client_invoke_wrapper_ptr->ctx_ref.SetMetaValue("aimrt-from_mqtt_client", client_id_);
|
||||
const auto& keys = client_invoke_wrapper_ptr->ctx_ref.GetMetaKeys();
|
||||
if (keys.size() > 255) [[unlikely]] {
|
||||
AIMRT_WARN("Too much context meta, require less than 255, but actually {}.", keys.size());
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "core/rpc/rpc_backend_base.h"
|
||||
#include "core/util/rpc_client_tool.h"
|
||||
#include "mqtt_plugin/msg_handle_registry.h"
|
||||
|
@ -222,6 +222,8 @@ bool NetPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcept {
|
||||
});
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
|
@ -162,6 +162,8 @@ bool OpenTelemetryPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcep
|
||||
[this] { RegisterRpcFilter(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
|
@ -15,12 +15,17 @@ struct convert<aimrt::plugins::parameter_plugin::ParameterPlugin::Options> {
|
||||
static Node encode(const Options& rhs) {
|
||||
Node node;
|
||||
|
||||
node["service_name"] = rhs.service_name;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, Options& rhs) {
|
||||
if (!node.IsMap()) return false;
|
||||
|
||||
if (node["service_name"])
|
||||
rhs.service_name = node["service_name"].as<std::string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -47,6 +52,8 @@ bool ParameterPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcept {
|
||||
[this] { RegisterRpcService(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
@ -70,9 +77,11 @@ void ParameterPlugin::SetPluginLogger() {
|
||||
}
|
||||
|
||||
void ParameterPlugin::RegisterRpcService() {
|
||||
// 注册rpc服务
|
||||
service_ptr_ = std::make_unique<ParameterServiceImpl>();
|
||||
|
||||
if (!options_.service_name.empty())
|
||||
service_ptr_->SetServiceName(options_.service_name);
|
||||
|
||||
service_ptr_->SetParameterManager(&(core_ptr_->GetParameterManager()));
|
||||
|
||||
auto rpc_handle_ref = aimrt::rpc::RpcHandleRef(
|
||||
|
@ -12,7 +12,9 @@ namespace aimrt::plugins::parameter_plugin {
|
||||
|
||||
class ParameterPlugin : public AimRTCorePluginBase {
|
||||
public:
|
||||
struct Options {};
|
||||
struct Options {
|
||||
std::string service_name;
|
||||
};
|
||||
|
||||
public:
|
||||
ParameterPlugin() = default;
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "core/aimrt_core.h"
|
||||
#include "core/channel/channel_backend_tools.h"
|
||||
#include "record_playback_plugin/global.h"
|
||||
#include "util/string_util.h"
|
||||
#include "util/time_util.h"
|
||||
|
||||
namespace YAML {
|
||||
@ -19,6 +18,8 @@ struct convert<aimrt::plugins::record_playback_plugin::RecordPlaybackPlugin::Opt
|
||||
static Node encode(const Options& rhs) {
|
||||
Node node;
|
||||
|
||||
node["service_name"] = rhs.service_name;
|
||||
|
||||
node["type_support_pkgs"] = YAML::Node();
|
||||
for (const auto& type_support_pkg : rhs.type_support_pkgs) {
|
||||
Node type_support_pkg_node;
|
||||
@ -48,6 +49,9 @@ struct convert<aimrt::plugins::record_playback_plugin::RecordPlaybackPlugin::Opt
|
||||
static bool decode(const Node& node, Options& rhs) {
|
||||
if (!node.IsMap()) return false;
|
||||
|
||||
if (node["service_name"])
|
||||
rhs.service_name = node["service_name"].as<std::string>();
|
||||
|
||||
if (node["type_support_pkgs"] && node["type_support_pkgs"].IsSequence()) {
|
||||
for (const auto& type_support_pkg_node : node["type_support_pkgs"]) {
|
||||
auto type_support_pkg = Options::TypeSupportPkg{
|
||||
@ -216,6 +220,8 @@ bool RecordPlaybackPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexce
|
||||
});
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
@ -273,6 +279,9 @@ void RecordPlaybackPlugin::InitTypeSupport(Options::TypeSupportPkg& options) {
|
||||
void RecordPlaybackPlugin::RegisterRpcService() {
|
||||
service_ptr_ = std::make_unique<RecordPlaybackServiceImpl>();
|
||||
|
||||
if (!options_.service_name.empty())
|
||||
service_ptr_->SetServiceName(options_.service_name);
|
||||
|
||||
service_ptr_->SetRecordActionMap(&record_action_map_);
|
||||
service_ptr_->SetPlaybackActionMap(&playback_action_map_);
|
||||
|
||||
|
@ -15,6 +15,8 @@ namespace aimrt::plugins::record_playback_plugin {
|
||||
class RecordPlaybackPlugin : public AimRTCorePluginBase {
|
||||
public:
|
||||
struct Options {
|
||||
std::string service_name;
|
||||
|
||||
struct TypeSupportPkg {
|
||||
std::string path;
|
||||
};
|
||||
|
@ -93,6 +93,8 @@ bool Ros2Plugin::Initialize(runtime::core::AimRTCore* core_ptr) noexcept {
|
||||
[this] { RegisterRos2ChannelBackend(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
|
@ -15,12 +15,17 @@ struct convert<aimrt::plugins::time_manipulator_plugin::TimeManipulatorPlugin::O
|
||||
static Node encode(const Options& rhs) {
|
||||
Node node;
|
||||
|
||||
node["service_name"] = rhs.service_name;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, Options& rhs) {
|
||||
if (!node.IsMap()) return false;
|
||||
|
||||
if (node["service_name"])
|
||||
rhs.service_name = node["service_name"].as<std::string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -50,6 +55,8 @@ bool TimeManipulatorPlugin::Initialize(runtime::core::AimRTCore* core_ptr) noexc
|
||||
[this] { RegisterRpcService(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
AIMRT_ERROR("Initialize failed, {}", e.what());
|
||||
@ -86,9 +93,11 @@ void TimeManipulatorPlugin::RegisterTimeManipulatorExecutor() {
|
||||
}
|
||||
|
||||
void TimeManipulatorPlugin::RegisterRpcService() {
|
||||
// 注册rpc服务
|
||||
service_ptr_ = std::make_unique<TimeManipulatorServiceImpl>();
|
||||
|
||||
if (!options_.service_name.empty())
|
||||
service_ptr_->SetServiceName(options_.service_name);
|
||||
|
||||
const auto& executor_vec = core_ptr_->GetExecutorManager().GetAllExecutors();
|
||||
|
||||
for (const auto& itr : executor_vec) {
|
||||
|
@ -12,7 +12,9 @@ namespace aimrt::plugins::time_manipulator_plugin {
|
||||
|
||||
class TimeManipulatorPlugin : public AimRTCorePluginBase {
|
||||
public:
|
||||
struct Options {};
|
||||
struct Options {
|
||||
std::string service_name;
|
||||
};
|
||||
|
||||
public:
|
||||
TimeManipulatorPlugin() = default;
|
||||
|
@ -58,6 +58,7 @@ bool ZenohPlugin::Initialize(runtime::core::AimRTCore *core_ptr) noexcept {
|
||||
[this] { RegisterZenohRpcBackend(); });
|
||||
|
||||
plugin_options_node = options_;
|
||||
core_ptr_->GetPluginManager().UpdatePluginOptionsNode(Name(), plugin_options_node);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "core/aimrt_core.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "core/util/version.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "aimrt_module_cpp_interface/channel/channel_handle.h"
|
||||
#include "core/channel/channel_backend_tools.h"
|
||||
#include "util/stl_tool.h"
|
||||
|
||||
namespace aimrt::runtime::core::channel {
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "aimrt_module_cpp_interface/util/function.h"
|
||||
#include "aimrt_module_c_interface/util/function_base.h"
|
||||
#include "core/channel/channel_backend_base.h"
|
||||
#include "core/channel/channel_framework_async_filter.h"
|
||||
#include "core/channel/channel_registry.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "aimrt_module_c_interface/channel/channel_handle_base.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "aimrt_module_cpp_interface/util/type_support.h"
|
||||
#include "core/channel/channel_backend_manager.h"
|
||||
#include "util/log_util.h"
|
||||
#include "util/string_util.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "aimrt_module_cpp_interface/channel/channel_context.h"
|
||||
#include "aimrt_module_cpp_interface/util/type_support.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
// All rights reserved.
|
||||
|
||||
#include "core/executor/asio_thread_executor.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "core/util/thread_tools.h"
|
||||
|
||||
namespace YAML {
|
||||
|
@ -4,10 +4,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
#include "aimrt_module_cpp_interface/executor/executor_manager.h"
|
||||
#include "aimrt_module_cpp_interface/util/function.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "aimrt_module_c_interface/executor/executor_manager_base.h"
|
||||
#include "core/executor/executor_base.h"
|
||||
#include "util/log_util.h"
|
||||
#include "util/string_util.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
// All rights reserved.
|
||||
|
||||
#include "core/executor/tbb_thread_executor.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "core/util/thread_tools.h"
|
||||
|
||||
namespace YAML {
|
||||
|
@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <shared_mutex>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
|
@ -4,8 +4,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <string_view>
|
||||
|
||||
#include "core/logger/logger_backend_base.h"
|
||||
#include "aimrt_module_c_interface/logger/logger_base.h"
|
||||
|
||||
namespace aimrt::runtime::core::logger {
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "core/logger/logger_manager.h"
|
||||
#include "core/logger/console_logger_backend.h"
|
||||
#include "core/logger/log_level_tool.h"
|
||||
#include "core/logger/rotate_file_logger_backend.h"
|
||||
|
||||
namespace YAML {
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
#include "core/logger/log_level_tool.h"
|
||||
#include "core/logger/logger_proxy.h"
|
||||
#include "core/util/module_detail_info.h"
|
||||
#include "util/log_util.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <shared_mutex>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "aimrt_module_c_interface/core_base.h"
|
||||
|
||||
namespace aimrt::runtime::core::module {
|
||||
|
@ -4,16 +4,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "aimrt_module_c_interface/logger/logger_base.h"
|
||||
#include "aimrt_module_cpp_interface/util/function.h"
|
||||
#include "aimrt_module_cpp_interface/util/string.h"
|
||||
#include "core/module/core_proxy.h"
|
||||
#include "core/module/module_loader.h"
|
||||
|
@ -3,13 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "aimrt_module_c_interface/parameter/parameter_handle_base.h"
|
||||
#include "util/log_util.h"
|
||||
#include "util/string_util.h"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "aimrt_module_c_interface/parameter/parameter_handle_base.h"
|
||||
#include "core/parameter/parameter_handle.h"
|
||||
#include "core/parameter/parameter_handle_proxy.h"
|
||||
#include "core/util/module_detail_info.h"
|
||||
|
@ -191,6 +191,20 @@ YAML::Node PluginManager::GetPluginOptionsNode(std::string_view plugin_name) con
|
||||
return YAML::Node();
|
||||
}
|
||||
|
||||
void PluginManager::UpdatePluginOptionsNode(std::string_view plugin_name, YAML::Node options) {
|
||||
AIMRT_CHECK_ERROR_THROW(
|
||||
state_.load() == State::kInit,
|
||||
"Method can only be called when state is 'Init'.");
|
||||
|
||||
auto finditr = std::find_if(
|
||||
options_.plugins_options.begin(),
|
||||
options_.plugins_options.end(),
|
||||
[plugin_name](const auto& op) { return plugin_name == op.name; });
|
||||
|
||||
if (finditr != options_.plugins_options.end())
|
||||
finditr->options = options;
|
||||
}
|
||||
|
||||
std::list<std::pair<std::string, std::string>> PluginManager::GenInitializationReport() const {
|
||||
AIMRT_CHECK_ERROR_THROW(
|
||||
state_.load() == State::kInit,
|
||||
|
@ -51,6 +51,7 @@ class PluginManager {
|
||||
void RegisterCorePtr(AimRTCore* core_ptr);
|
||||
|
||||
YAML::Node GetPluginOptionsNode(std::string_view plugin_name) const;
|
||||
void UpdatePluginOptionsNode(std::string_view plugin_name, YAML::Node options);
|
||||
|
||||
State GetState() const { return state_.load(); }
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "aimrt_module_cpp_interface/rpc/rpc_handle.h"
|
||||
#include "aimrt_module_cpp_interface/rpc/rpc_status.h"
|
||||
#include "util/stl_tool.h"
|
||||
|
||||
namespace aimrt::runtime::core::rpc {
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "aimrt_module_c_interface/rpc/rpc_handle_base.h"
|
||||
#include "core/rpc/rpc_backend_manager.h"
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "aimrt_module_c_interface/rpc/rpc_handle_base.h"
|
||||
#include "aimrt_module_cpp_interface/executor/executor.h"
|
||||
#include "core/rpc/rpc_backend_manager.h"
|
||||
#include "core/rpc/rpc_handle_proxy.h"
|
||||
|
@ -4,8 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "core/rpc/rpc_invoke_wrapper.h"
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace aimrt::runtime::core::util {
|
||||
|
@ -213,7 +213,10 @@ inline void ExportRpcHandleRef(pybind11::object m) {
|
||||
pybind11::class_<RpcHandleRef>(std::move(m), "RpcHandleRef")
|
||||
.def(pybind11::init<>())
|
||||
.def("__bool__", &RpcHandleRef::operator bool)
|
||||
.def("RegisterService", &RpcHandleRef::RegisterService)
|
||||
.def("RegisterService",
|
||||
pybind11::overload_cast<std::string_view, aimrt::rpc::ServiceBase*>(&RpcHandleRef::RegisterService))
|
||||
.def("RegisterService",
|
||||
pybind11::overload_cast<aimrt::rpc::ServiceBase*>(&RpcHandleRef::RegisterService))
|
||||
.def("RegisterClientFunc", &PyRpcHandleRefRegisterClientFunc)
|
||||
.def("Invoke", &PyRpcHandleRefInvoke);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user