-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Byron Ruth <[email protected]>
- Loading branch information
Showing
7 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/sh | ||
|
||
set -euo pipefail | ||
|
||
# Define the system account to be included by all configurations. | ||
cat <<- EOF > accounts.conf | ||
accounts: { | ||
SYS: { | ||
users: [{user: sys, password: sys}] | ||
} | ||
APP: { | ||
jetstream: true | ||
users: [{user: app, password: app}] | ||
} | ||
} | ||
system_account: SYS | ||
EOF | ||
|
||
# Define configuration for two nodes. | ||
cat <<- EOF > n1.conf | ||
port: 4222 | ||
http_port: 8222 | ||
server_name: n1 | ||
include accounts.conf | ||
jetstream: {} | ||
cluster: { | ||
name: c1, | ||
port: 6222, | ||
routes: [ | ||
"nats-route://0.0.0.0:6222" | ||
"nats-route://0.0.0.0:6223" | ||
], | ||
} | ||
EOF | ||
|
||
cat <<- EOF > n2.conf | ||
port: 4223 | ||
http_port: 8223 | ||
server_name: n2 | ||
include accounts.conf | ||
jetstream: {} | ||
cluster: { | ||
name: c1, | ||
port: 6223, | ||
routes: [ | ||
"nats-route://0.0.0.0:6222" | ||
"nats-route://0.0.0.0:6223" | ||
], | ||
} | ||
EOF | ||
|
||
|
||
# Start the servers and sleep for a few seconds to startup. | ||
nats-server -c n1.conf & #> /dev/null 2>&1 & | ||
nats-server -c n2.conf & #> /dev/null 2>&1 & | ||
|
||
sleep 3 | ||
|
||
|
||
# Wait until the servers are healthy. | ||
curl --fail --silent \ | ||
--retry 5 \ | ||
--retry-delay 1 \ | ||
http://localhost:8222/healthz > /dev/null | ||
|
||
curl --fail --silent \ | ||
--retry 5 \ | ||
--retry-delay 1 \ | ||
http://localhost:8223/healthz > /dev/null | ||
|
||
|
||
# Save a couple NATS CLI contexts for convenience. | ||
nats context save app \ | ||
--server "nats://localhost:4222" --user app --password app > /dev/null | ||
|
||
nats context select app | ||
|
||
nats stream add --config n1.json | ||
nats stream add --config n2.json | ||
|
||
nats stream edit --force --config n1-edit.json n1 | ||
nats stream edit --force --config n2-edit.json n2 | ||
|
||
nats req 'n1.1' '' | ||
nats req 'n2.1' '' | ||
|
||
nats stream list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "n1", | ||
"subjects": [ | ||
"n1.\u003e" | ||
], | ||
"retention": "limits", | ||
"max_consumers": -1, | ||
"max_msgs_per_subject": -1, | ||
"max_msgs": -1, | ||
"max_bytes": -1, | ||
"max_age": 0, | ||
"max_msg_size": -1, | ||
"storage": "file", | ||
"discard": "old", | ||
"num_replicas": 1, | ||
"duplicate_window": 12000000000, | ||
"sealed": false, | ||
"deny_delete": false, | ||
"deny_purge": false, | ||
"allow_rollup_hdrs": true, | ||
"sources": [ | ||
{ | ||
"name": "n2", | ||
"filter_subject": "n2.\u003e", | ||
"opt_start_seq": 0, | ||
"opt_start_time": "0001-01-01T00:00:00Z", | ||
"external": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "n1", | ||
"subjects": [ | ||
"n1.\u003e" | ||
], | ||
"retention": "limits", | ||
"max_consumers": -1, | ||
"max_msgs_per_subject": -1, | ||
"max_msgs": -1, | ||
"max_bytes": -1, | ||
"max_age": 0, | ||
"max_msg_size": -1, | ||
"storage": "file", | ||
"discard": "old", | ||
"num_replicas": 1, | ||
"duplicate_window": 12000000000, | ||
"sealed": false, | ||
"deny_delete": false, | ||
"deny_purge": false, | ||
"allow_rollup_hdrs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "n2", | ||
"subjects": [ | ||
"n2.\u003e" | ||
], | ||
"retention": "limits", | ||
"max_consumers": -1, | ||
"max_msgs_per_subject": -1, | ||
"max_msgs": -1, | ||
"max_bytes": -1, | ||
"max_age": 0, | ||
"max_msg_size": -1, | ||
"storage": "file", | ||
"discard": "old", | ||
"num_replicas": 1, | ||
"duplicate_window": 12000000000, | ||
"sealed": false, | ||
"deny_delete": false, | ||
"deny_purge": false, | ||
"allow_rollup_hdrs": true, | ||
"sources": [ | ||
{ | ||
"name": "n1", | ||
"filter_subject": "n1.\u003e" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "n2", | ||
"subjects": [ | ||
"n2.\u003e" | ||
], | ||
"retention": "limits", | ||
"max_consumers": -1, | ||
"max_msgs_per_subject": -1, | ||
"max_msgs": -1, | ||
"max_bytes": -1, | ||
"max_age": 0, | ||
"max_msg_size": -1, | ||
"storage": "file", | ||
"discard": "old", | ||
"num_replicas": 1, | ||
"duplicate_window": 12000000000, | ||
"sealed": false, | ||
"deny_delete": false, | ||
"deny_purge": false, | ||
"allow_rollup_hdrs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: '3.9' | ||
services: | ||
app: | ||
image: ${IMAGE_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
title: Faux active-active with stream sources | ||
description: |- |
2d2d75a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for nats-by-example ready!
✅ Preview
https://nats-by-example-f352rm43j-connecteverything.vercel.app
Built with commit 2d2d75a.
This pull request is being automatically deployed with vercel-action