Skip to content

Commit 351f73a

Browse files
committed
Ensure streams are created before source edits
Signed-off-by: Byron Ruth <byron@nats.io>
1 parent 8014c81 commit 351f73a

8 files changed

Lines changed: 39 additions & 184 deletions

File tree

examples/topologies/multi-region/cli/contexts/central-system.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/contexts/central-user.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/contexts/east-system.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/contexts/east-user.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/contexts/west-system.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/contexts/west-user.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/topologies/multi-region/cli/docker-compose.yaml

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@ version: '3'
33
services:
44
n1.east.example.net:
55
container_name: n1-east
6-
image: nats
6+
image: synadia/nats-server:nightly-main
77
dns_search: example.net
88
environment:
99
GATEWAY: c1
1010
NAME: n1-east
1111
ADVERTISE: localhost:10000
1212
REGION: region:east
13-
networks:
14-
- nats-cluster1
15-
- shared
1613
volumes:
17-
- "./configs/cluster-east.conf:/nats-server.conf"
18-
- "./data/n1-east:/data"
14+
- "./configs/cluster-east.conf:/nats/conf/nats-server.conf"
1915
ports:
2016
- 10000:4222
2117
- 10100:7422
2218
n2.east.example.net:
2319
container_name: n2-east
24-
image: nats
20+
image: synadia/nats-server:nightly-main
2521
dns_search: example.net
2622
labels:
2723
com.docker-tc.enabled: '1'
@@ -30,138 +26,106 @@ services:
3026
NAME: n2-east
3127
ADVERTISE: localhost:10001
3228
REGION: region:east
33-
networks:
34-
- nats-cluster1
35-
- shared
3629
volumes:
37-
- "./configs/cluster-east.conf:/nats-server.conf"
38-
- "./data/n2-east:/data"
30+
- "./configs/cluster-east.conf:/nats/conf/nats-server.conf"
3931
ports:
4032
- 10001:4222
4133
- 10101:7422
4234
n3.east.example.net:
4335
container_name: n3-east
44-
image: nats
36+
image: synadia/nats-server:nightly-main
4537
dns_search: example.net
4638
environment:
4739
GATEWAY: c1
4840
NAME: n3-east
4941
ADVERTISE: localhost:10002
5042
REGION: region:east
51-
networks:
52-
- nats-cluster1
53-
- shared
5443
volumes:
55-
- "./configs/cluster-east.conf:/nats-server.conf"
56-
- "./data/n3-east:/data"
44+
- "./configs/cluster-east.conf:/nats/conf/nats-server.conf"
5745
ports:
5846
- 10002:4222
5947
- 10102:7422
6048
n1.central.example.net:
6149
container_name: n1-central
62-
image: nats
50+
image: synadia/nats-server:nightly-main
6351
dns_search: example.net
6452
environment:
6553
GATEWAY: c1
6654
NAME: n1-central
6755
ADVERTISE: localhost:10003
6856
REGION: region:central
69-
networks:
70-
- nats-cluster1
71-
- shared
7257
volumes:
73-
- "./configs/cluster-central.conf:/nats-server.conf"
74-
- "./data/n1-central:/data"
58+
- "./configs/cluster-central.conf:/nats/conf/nats-server.conf"
7559
ports:
7660
- 10003:4222
7761
- 10103:7422
7862
n2.central.example.net:
7963
container_name: n2-central
80-
image: nats
64+
image: synadia/nats-server:nightly-main
8165
dns_search: example.net
8266
environment:
8367
GATEWAY: c1
8468
NAME: n2-central
8569
ADVERTISE: localhost:10004
8670
REGION: region:central
87-
networks:
88-
- nats-cluster1
89-
- shared
9071
volumes:
91-
- "./configs/cluster-central.conf:/nats-server.conf"
92-
- "./data/n2-central:/data"
72+
- "./configs/cluster-central.conf:/nats/conf/nats-server.conf"
9373
ports:
9474
- 10004:4222
9575
- 10104:7422
9676
n3.central.example.net:
9777
container_name: n3-central
98-
image: nats
78+
image: synadia/nats-server:nightly-main
9979
dns_search: example.net
10080
environment:
10181
GATEWAY: c1
10282
NAME: n3-central
10383
ADVERTISE: localhost:10005
10484
REGION: region:central
105-
networks:
106-
- nats-cluster1
107-
- shared
10885
volumes:
109-
- "./configs/cluster-central.conf:/nats-server.conf"
110-
- "./data/n3-central:/data"
86+
- "./configs/cluster-central.conf:/nats/conf/nats-server.conf"
11187
ports:
11288
- 10005:4222
11389
- 10105:7422
11490
n1.west.example.net:
11591
container_name: n1-west
116-
image: nats
92+
image: synadia/nats-server:nightly-main
11793
dns_search: example.net
11894
environment:
11995
GATEWAY: c1
12096
NAME: n1-west
12197
ADVERTISE: localhost:10006
12298
REGION: region:west
123-
networks:
124-
- nats-cluster1
125-
- shared
12699
volumes:
127-
- "./configs/cluster-west.conf:/nats-server.conf"
128-
- "./data/n1-west:/data"
100+
- "./configs/cluster-west.conf:/nats/conf/nats-server.conf"
129101
ports:
130102
- 10006:4222
131103
- 10106:7422
132104
n2.west.example.net:
133105
container_name: n2-west
134-
image: nats
106+
image: synadia/nats-server:nightly-main
135107
dns_search: example.net
136108
environment:
137109
GATEWAY: c1
138110
NAME: n2-west
139111
ADVERTISE: localhost:10007
140112
REGION: region:west
141-
networks:
142-
- nats-cluster1
143-
- shared
144113
volumes:
145-
- "./configs/cluster-west.conf:/nats-server.conf"
146-
- "./data/n2-west:/data"
114+
- "./configs/cluster-west.conf:/nats/conf/nats-server.conf"
147115
ports:
148116
- 10007:4222
149117
- 10107:7422
150118
n3.west.example.net:
151119
container_name: n3-west
152-
image: nats
120+
image: synadia/nats-server:nightly-main
153121
dns_search: example.net
154122
environment:
155123
GATEWAY: c1
156124
NAME: n3-west
157125
ADVERTISE: localhost:10008
158126
REGION: region:west
159-
networks:
160-
- nats-cluster1
161-
- shared
162127
volumes:
163-
- "./configs/cluster-west.conf:/nats-server.conf"
164-
- "./data/n3-west:/data"
128+
- "./configs/cluster-west.conf:/nats/conf/nats-server.conf"
165129
ports:
166130
- 10008:4222
167131
- 10108:7422
@@ -177,9 +141,3 @@ services:
177141
- n1.central.example.net
178142
- n2.central.example.net
179143
- n3.central.example.net
180-
networks:
181-
- shared
182-
183-
networks:
184-
shared: {}
185-
nats-cluster1: {}

examples/topologies/multi-region/cli/main.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ set -euo pipefail
44

55
sleep 3
66

7+
# Save a few contexts.
8+
nats context save east-sys \
9+
--server nats://n1.east.example.net:4222 \
10+
--user system \
11+
--password secret
12+
713
nats context save east \
814
--server nats://n1.east.example.net:4222 \
915
--user one \
@@ -19,10 +25,17 @@ nats context save central \
1925
--user one \
2026
--password secret
2127

28+
# Report the servers.
29+
nats --context east-sys server list
30+
31+
nats --context east stream add ORDERS_EAST --tag region:east --replicas 3 --subjects js.in.orders_east --defaults
32+
nats --context west stream add ORDERS_WEST --tag region:west --replicas 3 --subjects js.in.orders_west --defaults
33+
nats --context central stream add ORDERS_CENTRAL --tag region:central --replicas 3 --subjects js.in.orders_central --defaults
34+
2235
# Creating a region-local stream requires setting a tag for the desired region.
23-
nats --context east stream add --config /app/ORDERS_EAST.json
24-
nats --context west stream add --config /app/ORDERS_WEST.json
25-
nats --context central stream add --config /app/ORDERS_CENTRAL.json
36+
nats --context east stream edit ORDERS_EAST --force --config /app/ORDERS_EAST.json
37+
nats --context west stream edit ORDERS_WEST --force --config /app/ORDERS_WEST.json
38+
nats --context central stream edit ORDERS_CENTRAL --force --config /app/ORDERS_CENTRAL.json
2639

2740
# Creating a global stream involves ommitting the --tag option.
2841
nats --context east stream add --config /app/GLOBAL.json
@@ -32,8 +45,8 @@ nats --context east stream report
3245

3346
# Publish a message from a client in each region.
3447
nats --context east req js.in.orders 1
35-
nats --context west req js.in.orders 1
3648
nats --context central req js.in.orders 1
49+
nats --context west req js.in.orders 1
3750

3851
# Publish a message to the global stream.
3952
nats --context east req js.in.global.orders 1
@@ -42,3 +55,7 @@ sleep 1
4255

4356
# Let's see the stream report again.
4457
nats --context east stream report
58+
59+
nats --context east stream view ORDERS_EAST
60+
nats --context central stream view ORDERS_CENTRAL
61+
nats --context west stream view ORDERS_WEST

0 commit comments

Comments
 (0)