Skip to content

Commit 2ea452e

Browse files
committed
Add NATS modules to modules-contrib
Add five community-contributed modules that integrate OpenSIPS with NATS and JetStream: nats shared connection pool and libnats loader event_nats event transport over NATS subjects and JetStream cachedb_nats cachedb backend on JetStream KV (usrloc, b2b) cachedb_nats_fts optional full-text search for cachedb_nats nats_consumer JetStream pull consumer with request/reply The modules load libnats 3.14 or later with dlopen. Also add Debian and RPM packaging entries and a libnats install script. Each module carries its unit tests as a <module>/test/ suite run by unittests.yml (make test-<module>); the CI legs install libnats, and a suite whose module was not built is skipped. The end-to-end checks are SIPssert scenarios for sipssert-opensips-tests.
1 parent 804e092 commit 2ea452e

314 files changed

Lines changed: 78167 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/unittests.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ jobs:
127127
- name: Install dependencies
128128
run: sh -x scripts/build/install_depends.sh
129129

130+
# The NATS modules (modules-contrib/) need libnats >= 3.14, which no
131+
# Ubuntu release ships; without it they build nothing and their suites
132+
# are skipped. The cross legs build in another container: there the
133+
# script skips itself and so do the suites.
134+
- name: Install libnats
135+
if: ${{ !endsWith(matrix.compiler, '-cross') }}
136+
run: sh -x scripts/build/install_libnats.sh
137+
130138
- name: Get libtap
131139
run: git clone https://github.com/zorgnax/libtap.git lib/libtap
132140

‎Makefile.test‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,24 @@ unit_tests: ensure_test_defs $(NAME)
3939

4040
# One target per module suite. The module is a prerequisite because `make all`
4141
# builds only the modules/ collection (Makefile:113), leaving a contrib module
42-
# with no .so for its suite to load.
42+
# with no .so for its suite to load -- and so are the other contrib modules
43+
# its config loads.
44+
test_cfg_contrib_modules=$(filter $(enabled_module_paths), \
45+
$(wildcard $(addprefix modules-contrib/, \
46+
$(shell sed -n 's/^loadmodule "\(.*\)\.so".*/\1/p' \
47+
$(1)/test/opensips.cfg))))
48+
49+
# A module whose optional library is missing builds no .so (its Makefile
50+
# skips itself, e.g. the NATS modules without libnats): there is nothing to
51+
# load, so its suite is skipped rather than failed.
4352
define module_test_rule
44-
test-$(notdir $(1)): ensure_test_defs $$(NAME) $(1)
53+
test-$(notdir $(1)): ensure_test_defs $$(NAME) $(1) $(call test_cfg_contrib_modules,$(1))
4554
-@echo " ==== $(notdir $(1)) ===="
46-
./$$(NAME) -dd -T $(notdir $(1)) -w .
55+
@if [ ! -f $(1)/$(notdir $(1)).so ]; then \
56+
echo " skipped: $(notdir $(1)).so was not built"; \
57+
else \
58+
./$$(NAME) -dd -T $(notdir $(1)) -w .; \
59+
fi
4760
endef
4861
$(foreach m,$(test_module_paths),$(eval $(call module_test_rule,$(m))))
4962

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# WARNING: do not run this directly, it should be run by the master Makefile
2+
3+
include ../../Makefile.defs
4+
5+
# External libnats dependency probe (sets NATS_FOUND if available).
6+
include ../nats/Makefile.nats
7+
8+
ifeq ($(NATS_FOUND),)
9+
$(info [skip] cachedb_nats.so — libnats C client not detected (install libnats-dev or set LOCALBASE))
10+
.PHONY: all clean install modules
11+
all clean install modules: ; @true
12+
else
13+
14+
auto_gen=
15+
NAME=cachedb_nats.so
16+
17+
18+
# EVI support for E_NATS_KV_CHANGE events (KV watcher -> OpenSIPS scripts)
19+
20+
LIBS += -lpthread
21+
22+
include ../../Makefile.modules
23+
24+
25+
endif

0 commit comments

Comments
 (0)