Skip to content
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

[Merge from dev] nats v2.10 support #684

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ cmake-build*/
install/
html/
!doc/html/
test/datastore_*/
test/conf_*

# Emacs
*~
Expand Down
36 changes: 32 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: cpp
dist: bionic
dist: focal
os: linux

cache:
Expand All @@ -25,6 +25,34 @@ env:
jobs:
include:

- name: "NATS server - latest release"
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: ppa:ubuntu-toolchain-r/test
packages:
- g++-9
env:
- NATS_TEST_SERVER_VERSION=latest
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release" DO_COVERAGE="no"

- name: "NATS server - main"
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: ppa:ubuntu-toolchain-r/test
packages:
- g++-9
env:
- NATS_TEST_SERVER_VERSION=main
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release" DO_COVERAGE="no"

- name: "gcc-9 - TLS OFF"
compiler: gcc
addons:
Expand Down Expand Up @@ -62,7 +90,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "gcc-9 - Lib msg delivery - sanitize address"
compiler: gcc
Expand All @@ -75,7 +103,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- NATS_DEFAULT_TO_LIB_MSG_DELIVERY=yes BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"
- NATS_DEFAULT_TO_LIB_MSG_DELIVERY=yes BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fsanitize=address" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "gcc-9 - Write deadline - sanitize address"
compiler: gcc
Expand All @@ -101,7 +129,7 @@ jobs:
- g++-9
env:
- MATRIX_EVAL="CC=gcc-9"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=thread" DO_COVERAGE="no"
- BUILD_OPT="-DNATS_BUILD_ARCH=64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fsanitize=thread" NATS_TEST_VALGRIND=yes DO_COVERAGE="no"

- name: "clang-8 - TLS OFF"
compiler: clang
Expand Down
21 changes: 20 additions & 1 deletion buildOnTravis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ echo "coverage = " $2
echo "build opts = " $3
echo "test opts = " $4

if [ "$NATS_TEST_SERVER_VERSION" != "" ]; then
rel=$NATS_TEST_SERVER_VERSION
mkdir -p $HOME/nats-server-$rel
if [ "$rel" = "latest" ]; then
rel=$(curl -s https://api.github.com/repos/nats-io/nats-server/releases/latest | jq -r '.tag_name')
fi

if [ "$rel" != "${rel#v}" ] && wget https://github.com/nats-io/nats-server/releases/download/$rel/nats-server-$rel-linux-amd64.tar.gz; then
tar -xzf nats-server-$rel-linux-amd64.tar.gz
mv nats-server-$rel-linux-amd64 $HOME/nats-server-$rel
else
curl -sf "https://binaries.nats.dev/nats-io/nats-server/v2@$rel" | PREFIX=. sh
mv nats-server $HOME/nats-server-$rel
fi
PATH=$HOME/nats-server-$rel:$PATH
fi

if [ "$1" != "gcc" ]; then
if [ "$2" = "coverage" ]; then
# only coverage for gcc compiler
Expand All @@ -35,8 +52,10 @@ res=$?
if [ $res -ne 0 ]; then
exit $res
fi
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"

export NATS_TEST_TRAVIS=yes
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"
echo "Using NATS server version: $NATS_TEST_SERVER_VERSION"
ctest --timeout 60 --output-on-failure $4
res=$?
if [ $res -ne 0 ]; then
Expand Down
28 changes: 22 additions & 6 deletions src/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -2201,18 +2201,34 @@ _processConsInfo(const char **dlvSubject, jsConsumerInfo *info, jsConsumerConfig
jsConsumerConfig *ccfg = info->Config;
const char *dg = NULL;
natsStatus s = NATS_OK;
bool matches = false;
int i;

*dlvSubject = NULL;

// Make sure this new subject matches or is a subset.
if (!nats_IsStringEmpty(subj)
&& !nats_IsStringEmpty(ccfg->FilterSubject)
&& (strcmp(subj, ccfg->FilterSubject) != 0))
if (!nats_IsStringEmpty(subj))
{
return nats_setError(NATS_ERR, "subject '%s' does not match consumer filter subject '%s'",
subj, ccfg->FilterSubject);
if (nats_IsStringEmpty(ccfg->FilterSubject) && (ccfg->FilterSubjectsLen == 0))
{
matches = true;
}
else if (!nats_IsStringEmpty(ccfg->FilterSubject) && nats_HasPrefix(subj, ccfg->FilterSubject))
{
matches = true;
}
else if (ccfg->FilterSubjectsLen > 0)
{
for (i = 0; (i < ccfg->FilterSubjectsLen) && !matches; i++)
{
matches = nats_HasPrefix(subj, ccfg->FilterSubjects[i]);
}
}
if (!matches)
{
return nats_setError(NATS_ERR, "subject '%s' does not match any consumer filter subjects.", subj);
}
}

// Check that if user wants to create a queue sub,
// the consumer has no HB nor FC.
queue = (nats_IsStringEmpty(queue) ? NULL : queue);
Expand Down
3 changes: 3 additions & 0 deletions src/js.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ extern const int64_t jsDefaultRequestWait;
#define jsStorageTypeFileStr "file"
#define jsStorageTypeMemStr "memory"

#define jsStorageCompressionNoneStr "none"
#define jsStorageCompressionS2Str "s2"

#define jsDeliverAllStr "all"
#define jsDeliverLastStr "last"
#define jsDeliverNewStr "new"
Expand Down
Loading