Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Byron Ruth <[email protected]>
  • Loading branch information
bruth committed Jan 27, 2023
1 parent 613403d commit 2d2d75a
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 0 deletions.
94 changes: 94 additions & 0 deletions examples/use-cases/faux-active-active/cli/main.sh
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
30 changes: 30 additions & 0 deletions examples/use-cases/faux-active-active/cli/n1-edit.json
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
}
]
}
21 changes: 21 additions & 0 deletions examples/use-cases/faux-active-active/cli/n1.json
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
}
27 changes: 27 additions & 0 deletions examples/use-cases/faux-active-active/cli/n2-edit.json
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"
}
]
}
21 changes: 21 additions & 0 deletions examples/use-cases/faux-active-active/cli/n2.json
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
}
4 changes: 4 additions & 0 deletions examples/use-cases/faux-active-active/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: '3.9'
services:
app:
image: ${IMAGE_TAG}
2 changes: 2 additions & 0 deletions examples/use-cases/faux-active-active/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Faux active-active with stream sources
description: |-

1 comment on commit 2d2d75a

@github-actions
Copy link

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

Please sign in to comment.