Skip to content

Add NATS modules to modules-contrib - #4442

Open
NormB wants to merge 1 commit into
OpenSIPS:masterfrom
NormB:nats/upstream-cleanup
Open

NormB wants to merge 1 commit into
OpenSIPS:masterfrom
NormB:nats/upstream-cleanup

Conversation

@NormB

@NormB NormB commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Summary
Add five community-contributed modules under modules-contrib/ that integrate OpenSIPS with NATS and JetStream. Like all contrib modules, they are excluded from the default make and make install targets and are built only when selected explicitly.

Details

Module Purpose Production C (approx. lines)
nats Shared connection pool and libnats loader; the only module that talks to libnats 10,000 together with event_nats
event_nats Event transport publishing to NATS subjects and JetStream Counted with nats
cachedb_nats cachedb backend on JetStream KV, for usrloc and b2b 14,900
cachedb_nats_fts Optional full-text search add-on for cachedb_nats 3,400
nats_consumer JetStream pull consumer with a shared-memory ring and request/reply 13,900

cachedb_nats, event_nats and nats_consumer bind to nats.so at runtime through load_nats_api. cachedb_nats_fts plugs into cachedb_nats.

The change is 314 files, 78,167 insertions and 8 deletions. Of those, 308 files and 77,857 lines are under modules-contrib/, 179 files and 27,754 lines of them the unit tests (each module's test/ suite).

Solution

The modules load libnats with dlopen and never link -lnats, so packages need it only as a build dependency. The libnats found at runtime must have the same major.minor as the build headers, or OpenSIPS refuses to start. If libnats is missing or too old at build time, each module is skipped without failing the build.

Dependencies

Dependency Needed for Minimum Source
libnats (nats.c) Building and running all five modules 3.14 nats.c v3.14.0; Debian trixie's libnats-dev 3.10.1 is too old
nats-server with JetStream Running 2.10 nats-server releases
tls_mgm and a TLS-enabled libnats tls:// URLs only None -DNATS_BUILD_WITH_TLS=ON

Build

LIBNATS_TLS=ON scripts/build/install_libnats.sh
make all
make modules-contrib modules="modules-contrib/nats modules-contrib/cachedb_nats modules-contrib/cachedb_nats_fts modules-contrib/event_nats modules-contrib/nats_consumer"

To load them, include both module trees in mpath and load nats.so before the others.

Test

Each module has a unit-test suite in modules-contrib/<module>/test/, run in the existing layout by unittests.yml (the CI legs now install libnats; a suite whose module was not built is skipped):

make test-nats test-event_nats test-nats_consumer test-cachedb_nats_fts test-cachedb_nats

The end-to-end checks are SIPssert scenarios kept with the modules' maintainer, on the nats-sets branch of NormB/sipssert-opensips-tests (sets nats, event_nats, cachedb_nats, nats_consumer; they need an image with the NATS modules).

Verification

Local checks ran on Debian 13: the unit suites with gcc 14 (with -D_FORTIFY_SOURCE=2) and clang 19 (-O3), against nats.c 3.15.0-beta, the SIPssert sets against an image with nats.c v3.14.0 (the pinned install_libnats.sh version) and nats-server 2.11.10.

Check Result
Build of the 5 modules, -Werror, on current master 0 warnings
Unit suites (make test-<module>), gcc and clang 5 of 5 pass: 655, 181, 817, 131 and 1,197 assertions
A suite whose module is not built (no libnats) Skipped, not failed
SIPssert sets (NormB/sipssert-opensips-tests, nats-sets) 13 of 13 scenarios pass

Compatibility
These are new contrib modules, with no changes to core or existing module code. Outside modules-contrib/, the branch adds Debian and RPM packaging entries and a libnats install script, installs libnats in unittests.yml, and makes Makefile.test skip a module suite whose module was not built.

Closing issues
None.

@NormB
NormB requested a review from razvancrainea November 9, 2026 14:09
@NormB NormB closed this Nov 9, 2026
@NormB NormB reopened this Nov 9, 2026
NormB added a commit to NormB/NormB that referenced this pull request Nov 9, 2026
Move the NATS modules from the not-yet-upstream list to an open pull
request, OpenSIPS/opensips#4442, and name the five modules it adds.
Update the counts from the GitHub search and Open VSX: 75 merged upstream
pull requests (OpenSIPS 48, 37 in 2026), 75,000+ language-server installs,
and the LSP releases, now 0.28.1 and 0.22.1. vcon-server is at 0.4.1.
@razvancrainea razvancrainea self-assigned this Nov 10, 2026
@NormB NormB closed this Nov 10, 2026
@NormB NormB reopened this Nov 10, 2026
@NormB
NormB force-pushed the nats/upstream-cleanup branch from e7eabc6 to 6411a3d Compare November 10, 2026 20:09
@NormB
NormB force-pushed the nats/upstream-cleanup branch 3 times, most recently from 2303cff to 2ea452e Compare November 10, 2026 21:09
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.
@NormB
NormB force-pushed the nats/upstream-cleanup branch from 2ea452e to 5341de2 Compare November 11, 2026 14:23
@NormB NormB closed this Nov 11, 2026
@NormB NormB reopened this Nov 11, 2026
@NormB NormB closed this Nov 11, 2026
@NormB NormB reopened this Nov 11, 2026
@NormB NormB closed this Nov 11, 2026
@NormB NormB reopened this Nov 11, 2026
@NormB NormB closed this Nov 12, 2026
@NormB NormB reopened this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants