Skip to content

Dphan/add nats #5

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

Draft
wants to merge 49 commits into
base: dphan/update-to-cpp17
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
36de207
chores: update cmake version
dorotaphanSiili Oct 17, 2024
4c57139
docs: add tip for conan feature
dorotaphanSiili Oct 18, 2024
92d705c
add apigear nats to project
dorotaphanSiili Oct 26, 2024
56ece9a
add service and client to rules
dorotaphanSiili Nov 18, 2024
c1c0ed5
add generated nats adapters
dorotaphanSiili Oct 30, 2024
7544128
add nats base
dorotaphanSiili Oct 30, 2024
87e7e49
apigear nats handle connection status
dorotaphanSiili Oct 30, 2024
bbb09cf
subscriptions - split changes especially in cwrapper cpp
dorotaphanSiili Oct 31, 2024
0690585
nats apigear: wrap connection with unique ptr
dorotaphanSiili Nov 4, 2024
232d127
apigear nats: handle messages and cleaning subscriptions
dorotaphanSiili Nov 4, 2024
6a0445a
fixes for subscribing a callback
dorotaphanSiili Nov 5, 2024
1551f50
fix: handle connection
dorotaphanSiili Nov 5, 2024
549167d
make opts safe
dorotaphanSiili Nov 5, 2024
d9988ec
fixes for subscribtions
dorotaphanSiili Nov 5, 2024
6e3be0d
fixup for proper sub handling
dorotaphanSiili Nov 5, 2024
96b0074
remove logs handle message
dorotaphanSiili Nov 5, 2024
860be17
make clean resources in subscription a private function
dorotaphanSiili Nov 5, 2024
0dc8fcd
remove resources wrap ctx in unique ptr
dorotaphanSiili Nov 5, 2024
b479914
move handling error to instance of cwrapper
dorotaphanSiili Nov 5, 2024
532b5b7
fix: subscription
dorotaphanSiili Nov 5, 2024
817620a
handle errors on connect
dorotaphanSiili Nov 6, 2024
bf1644d
handle errors on subscribe
dorotaphanSiili Nov 6, 2024
45f543c
fixup log on subscribe
dorotaphanSiili Nov 6, 2024
3722b1c
use propert nats header
dorotaphanSiili Nov 6, 2024
e73f564
fix: fix string parameters
dorotaphanSiili Nov 6, 2024
1198e8b
fixup for base - no string copy
dorotaphanSiili Nov 6, 2024
947dd34
handle request-response
dorotaphanSiili Nov 7, 2024
15a67fc
extend log for subscribe
dorotaphanSiili Nov 7, 2024
20356a5
extend log for connect
dorotaphanSiili Nov 7, 2024
c1557ae
make subscriptions non-blocking
dorotaphanSiili Nov 7, 2024
7d3ad7e
add publisher helper
dorotaphanSiili Nov 14, 2024
eaac33a
add subscription helper for adapters (base adapter)
dorotaphanSiili Nov 14, 2024
1378587
add disconnect adn rename publishRequest - should be split
dorotaphanSiili Nov 14, 2024
f4a4f6c
add type for method callback
dorotaphanSiili Nov 14, 2024
1b995d7
add subscriptions enum
dorotaphanSiili Nov 14, 2024
31c6635
to split: disconnect, invalid id, rename publishRequest
dorotaphanSiili Nov 14, 2024
f6d514d
nats client template
dorotaphanSiili Nov 14, 2024
bba8cd9
fix for connect in base
dorotaphanSiili Nov 15, 2024
0e75bf7
base adapter fixup - no init
dorotaphanSiili Nov 18, 2024
3160483
client fixup - no init (still sth off)
dorotaphanSiili Nov 18, 2024
fa42844
generate service side adapters
dorotaphanSiili Nov 18, 2024
61882fc
fixup to add publisher helper
dorotaphanSiili Nov 21, 2024
b58df3b
change of build apigear in order to have a folder structure like for …
dorotaphanSiili Nov 22, 2024
4c1e6df
cwrapper fixes
dorotaphanSiili Nov 21, 2024
f331089
fixup for natsbase
dorotaphanSiili Nov 21, 2024
ac4a62b
fixes for base adapter: add thread safety
dorotaphanSiili Nov 21, 2024
639baec
cwrapper fixes for memory management
dorotaphanSiili Nov 21, 2024
0fe192b
fixup remove additional header natsbase
dorotaphanSiili Nov 21, 2024
47286cd
fix for nats cmake debug-release
dorotaphanSiili Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/docs/features/conan.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import helloWorldModuleComponent from '!!raw-loader!./data/helloworld.module.yam

With this feature you we generate a conan support for your project. It helps with packaging and to managing dependencies for different platforms, OSs, compilers, architecture, cross-builds. Read more about conan and its all benefits [here](https://conan.io/).

::tip::
Make sure your conan profile has all the required settings set to desired values e.g. the cpp standard set to 17.
:::

### File overview for module

Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/apigear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(apigear)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/apigear/olink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(poco-olink)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/apigear/olink/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(test_poco_olink)

set(SPDLOG_DEBUG_ON true)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/apigear/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(utilities)

set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/apigear/utilities/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(test_apigear_utilities)

set(SPDLOG_DEBUG_ON true)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(App)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/appthreadsafe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(AppThreadSafe)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/mqttclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(MQTTClient)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/mqttserver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(MQTTServer)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/olinkclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(OLinkClient)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/examples/olinkserver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(OLinkServer)

# append local binary directory for conan packages to be found
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/counter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(counter)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testcounter)
include(CTest)
find_package(counter CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/custom_types/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(custom_types)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testcustom_types)
include(CTest)
find_package(custom_types CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/extern_types/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(extern_types)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testextern_types)
include(CTest)
find_package(extern_types CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/tb_enum/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(tb_enum)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtb_enum)
include(CTest)
find_package(tb_enum CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/tb_names/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(tb_names)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtb_names)
include(CTest)
find_package(tb_names CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/tb_same1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(tb_same1)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtb_same1)
include(CTest)
find_package(tb_same1 CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/tb_same2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(tb_same2)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtb_same2)
include(CTest)
find_package(tb_same2 CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/tb_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(tb_simple)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtb_simple)
include(CTest)
find_package(tb_simple CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/testbed1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(testbed1)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtestbed1)
include(CTest)
find_package(testbed1 CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion goldenmaster/modules/testbed2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(testbed2)

# needed to access CMAKE_INSTALL_LIBDIR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(Testtestbed2)
include(CTest)
find_package(testbed2 CONFIG REQUIRED)
Expand Down
49 changes: 49 additions & 0 deletions rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,53 @@ features:
target: "{{lower (camel .Interface.Name)}}client.h"
- source: "module/generated/mqtt/mqttclient.cpp.tpl"
target: "{{lower (camel .Interface.Name)}}client.cpp"
- name: nats
requires:
- api
- core
- apigear
scopes:
- match: module
documents:
- source: "apigear/nats/CMakeLists.txt"
raw: true
- source: "apigear/nats/natstypes.h"
raw: true
- source: "apigear/nats/private/natscwrapper.cpp"
raw: true
- source: "apigear/nats/private/natscwrapper.h"
raw: true
- source: "apigear/nats/natsbase.cpp"
raw: true
- source: "apigear/nats/natsbase.h"
raw: true
- source: "apigear/nats/natsclient.cpp"
raw: true
- source: "apigear/nats/natsclient.h"
raw: true
- source: "apigear/nats/natsservice.cpp"
raw: true
- source: "apigear/nats/natsservice.h"
raw: true
- source: "apigear/nats/baseadapter.cpp"
raw: true
- source: "apigear/nats/baseadapter.h"
raw: true
- source: "apigear/nats/natscommon.h"
raw: true
- source: "module/generated/nats/CMakeLists.txt.tpl"
target: "modules/{{snake .Module.Name}}/generated/nats/CMakeLists.txt"
- match: interface
prefix: "modules/{{snake .Module.Name}}/generated/nats/"
documents:
- source: "module/generated/nats/natsservice.h.tpl"
target: "{{lower (camel .Interface.Name)}}service.h"
- source: "module/generated/nats/natsservice.cpp.tpl"
target: "{{lower (camel .Interface.Name)}}service.cpp"
- source: "module/generated/nats/natsclient.h.tpl"
target: "{{lower (camel .Interface.Name)}}client.h"
- source: "module/generated/nats/natsclient.cpp.tpl"
target: "{{lower (camel .Interface.Name)}}client.cpp"
- name: apigear
scopes:
- match: system
Expand All @@ -164,6 +211,8 @@ features:
raw: true
- source: "apigear/utilities/threadpool.h"
raw: true
- source: "apigear/utilities/single_pub.hpp"
raw: true
- source: "apigear/utilities/CMakeLists.txt"
raw: true
- source: "apigear/utilities/tests/CMakeLists.txt"
Expand Down
7 changes: 7 additions & 0 deletions templates/CMakeLists.txt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ if(NOT apigear_FOUND)
{{- end }}
{{- if $.Features.mqtt }}
set(APIGEAR_BUILD_WITH_MQTT ON CACHE INTERNAL "Enable support for MQTT")
{{- end }}
{{- if $.Features.nats }}
set(APIGEAR_BUILD_WITH_NATS ON CACHE INTERNAL "Enable support for Nats")
{{- end }}
FetchContent_Declare(apigear
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/apigear"
Expand Down Expand Up @@ -127,3 +130,7 @@ add_subdirectory(examples/olinkclient)
add_subdirectory(examples/mqttserver)
add_subdirectory(examples/mqttclient)
{{- end }}
{{- if .Features.examples_nats }}
add_subdirectory(examples/natsserver)
add_subdirectory(examples/natsclient)
{{- end }}
12 changes: 11 additions & 1 deletion templates/apigear/ApigearConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(APIGEAR_VERSION 3.7.0)
set(APIGEAR_BUILD_WITH_OLINK @APIGEAR_BUILD_WITH_OLINK@)
set(APIGEAR_BUILD_WITH_MONITOR @APIGEAR_BUILD_WITH_MONITOR@)
set(APIGEAR_BUILD_WITH_MQTT @APIGEAR_BUILD_WITH_MQTT@)
set(APIGEAR_BUILD_WITH_NATS @APIGEAR_BUILD_WITH_NATS@)

# make sure we have all needed dependencies
include(CMakeFindDependencyMacro)
Expand All @@ -18,7 +19,10 @@ find_dependency(eclipse-paho-mqtt-c COMPONENTS paho-mqtt3as-static REQUIRED)
# needed for paho-c, should be forwarded implicitly but is not
find_dependency(OpenSSL REQUIRED)
endif()
if(APIGEAR_BUILD_WITH_OLINK OR APIGEAR_BUILD_WITH_MONITOR OR APIGEAR_BUILD_WITH_MQTT)
if(APIGEAR_BUILD_WITH_NATS)
find_dependency(cnats COMPONENTS nats_static REQUIRED)
endif()
if(APIGEAR_BUILD_WITH_OLINK OR APIGEAR_BUILD_WITH_MONITOR OR APIGEAR_BUILD_WITH_MQTT OR APIGEAR_BUILD_WITH_NATS)
find_dependency(nlohmann_json REQUIRED)
endif()

Expand All @@ -32,6 +36,9 @@ endif()
if(APIGEAR_BUILD_WITH_MQTT)
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/ApiGearPahoMQTTTargets.cmake")
endif()
if(APIGEAR_BUILD_WITH_NATS)
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/ApiGearNatsTargets.cmake")
endif()

check_required_components(utilities)
if(APIGEAR_BUILD_WITH_MONITOR)
Expand All @@ -43,3 +50,6 @@ endif()
if(APIGEAR_BUILD_WITH_MQTT)
check_required_components(paho-mqtt)
endif()
if(APIGEAR_BUILD_WITH_NATS)
check_required_components(nats)
endif()
10 changes: 8 additions & 2 deletions templates/apigear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.24)
project(apigear)

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -16,6 +16,7 @@ option(BUILD_TESTING "Enable this option to build the test targets" OFF)
option(APIGEAR_BUILD_WITH_OLINK "Enables the build of the OLINK backend" OFF)
option(APIGEAR_BUILD_WITH_MONITOR "Enables the build of the monitoring support library" OFF)
option(APIGEAR_BUILD_WITH_MQTT "Enables the build of the MQTT backend" OFF)
option(APIGEAR_BUILD_WITH_NATS "Enables the build of the nats backend" OFF)
# this options is only here for the conan build until there is a conan based solution for objectlink-core
option(APIGEAR_FETCH_OLINKCORE "Fetch and build objectlink-core, if not pre-installed" OFF)

Expand Down Expand Up @@ -60,11 +61,16 @@ add_subdirectory(mqtt)
list(APPEND apigear_COMPONENTS "mqtt")
endif()

if(APIGEAR_BUILD_WITH_NATS)
add_subdirectory(nats)
list(APPEND apigear_COMPONENTS "nats")
endif()

include(CMakePackageConfigHelpers)
configure_package_config_file(ApigearConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/apigearConfig.cmake
INSTALL_DESTINATION ${InstallDir}
PATH_VARS APIGEAR_BUILD_WITH_MONITOR APIGEAR_BUILD_WITH_OLINK APIGEAR_BUILD_WITH_MQTT)
PATH_VARS APIGEAR_BUILD_WITH_MONITOR APIGEAR_BUILD_WITH_OLINK APIGEAR_BUILD_WITH_MQTT APIGEAR_BUILD_WITH_NATS)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/apigearConfigVersion.cmake
VERSION 3.7.0
Expand Down
Loading