Skip to content

Commit 9a5cc09

Browse files
committed
Update example
Signed-off-by: Byron Ruth <byron@nats.io>
1 parent 55c5733 commit 9a5cc09

File tree

2 files changed

+68
-48
lines changed

2 files changed

+68
-48
lines changed
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
FROM natsio/nats-box:0.13.3
1+
FROM golang:1.19-alpine3.17 AS build
2+
3+
RUN go install github.com/nats-io/natscli/nats@latest #allow-online-peer-remove
4+
RUN go install github.com/nats-io/nats-server/v2@main
5+
6+
FROM natsio/nats-box:0.13.2
27

38
RUN apk add bash curl
49

5-
COPY --from=nats:2.9.10 /nats-server /usr/local/bin/
10+
COPY --from=build /go/bin/nats-server /usr/local/bin/
11+
COPY --from=build /go/bin/nats /usr/local/bin/
612

713
COPY . .
814

915
ENTRYPOINT ["bash"]
1016

1117
CMD ["main.sh"]
18+
19+
#FROM natsio/nats-box:0.13.3
20+
21+
#RUN apk add bash curl
22+
23+
#COPY --from=nats:2.9.10 /nats-server /usr/local/bin/
24+
25+
#COPY . .
26+
27+
#ENTRYPOINT ["bash"]
28+
29+
#CMD ["main.sh"]

examples/issues/3724/cli/main.sh

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ leafnodes: {
2525
port: 14222
2626
server_name: hengli_1
2727
28-
accounts:{
29-
hengli:{
28+
accounts: {
29+
hengli: {
3030
jetstream: enabled
3131
users:[
3232
{user: _hengliConnUser_, password: _hengliConnUser_}
3333
{user: hengli, password: hengli, permissions: {
34-
publish:{
34+
publish: {
3535
allow:["hengli.to.wsw.test","\$JS.API.>"]
3636
},
37-
subscribe:{
37+
subscribe: {
3838
allow:["\$JS.ACK.hengli_to_wsw_test.>","_INBOX.>"]
3939
}
4040
}}
@@ -44,7 +44,6 @@ accounts:{
4444
EOF
4545

4646
cat <<- EOF > a_2.conf
47-
4847
cluster: {
4948
name: hengli
5049
port: 15334
@@ -65,16 +64,16 @@ leafnodes: {
6564
port: 14223
6665
server_name: hengli_2
6766
68-
accounts:{
69-
hengli:{
67+
accounts: {
68+
hengli: {
7069
jetstream: enabled
7170
users:[
7271
{user: _hengliConnUser_, password: _hengliConnUser_},
7372
{user: hengli, password: hengli, permissions: {
74-
publish:{
73+
publish: {
7574
allow:["hengli.to.wsw.test","\$JS.API.>"]
7675
},
77-
subscribe:{
76+
subscribe: {
7877
allow:["\$JS.ACK.hengli_to_wsw_test.>","_INBOX.>"]
7978
}
8079
}}
@@ -106,16 +105,16 @@ leafnodes: {
106105
port: 14224
107106
server_name: hengli_3
108107
109-
accounts:{
110-
hengli:{
108+
accounts: {
109+
hengli: {
111110
jetstream: enabled
112111
users:[
113112
{user: _hengliConnUser_, password: _hengliConnUser_},
114113
{user: hengli, password: hengli, permissions: {
115-
publish:{
114+
publish: {
116115
allow:["hengli.to.wsw.test","\$JS.API.>"]
117116
},
118-
subscribe:{
117+
subscribe: {
119118
allow:["\$JS.ACK.hengli_to_wsw_test.>","_INBOX.>"]
120119
}
121120
}}
@@ -124,6 +123,7 @@ accounts:{
124123
}
125124
EOF
126125

126+
# Setup the hub cluster.
127127
cat <<- EOF > "b_1.conf"
128128
http_port: 28222
129129
cluster: {
@@ -141,33 +141,35 @@ leafnodes: {
141141
port: 24222
142142
server_name: wsw_1
143143
144-
accounts:{
145-
hengli:{
144+
accounts: {
145+
hengli: {
146146
jetstream: enabled
147147
users:[
148148
{user: _hengliConnUser_, password: _hengliConnUser_}
149149
]
150150
exports:[
151151
{service: "\$JS.hengli.API.>", response: stream},
152+
{service: "\$JS.FC.>"},
152153
{stream: "deliver.hengli.wsw.>", accounts: ["wsw"]}
153154
]
154155
},
155-
wsw:{
156+
wsw: {
156157
jetstream: enabled
157158
users:[
158159
{user: _wswConnUser_, password: _wswConnUser_},
159160
{user: wsw, password: wsw, permissions: {
160-
publish:{
161+
publish: {
161162
allow:["\$JS.ACK.hengli_to_wsw_test.>"]
162163
},
163-
subscribe:{
164+
subscribe: {
164165
allow:["_recv_wsw.hengli.to.wsw.test"]
165166
}
166167
}}
167168
]
168169
imports:[
169-
{service:{account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
170-
{stream:{account:"hengli", subject:"deliver.hengli.wsw.>"}}
170+
{service: {account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
171+
{service: {account: "hengli", subject: "\$JS.FC.>"}},
172+
{stream: {account:"hengli", subject:"deliver.hengli.wsw.>"}}
171173
]
172174
}
173175
}
@@ -190,33 +192,35 @@ leafnodes: {
190192
port: 24223
191193
server_name: wsw_2
192194
193-
accounts:{
194-
hengli:{
195+
accounts: {
196+
hengli: {
195197
jetstream: enabled
196198
users:[
197199
{user: _hengliConnUser_, password: _hengliConnUser_}
198200
]
199201
exports:[
200202
{service: "\$JS.hengli.API.>", response: stream},
203+
{service: "\$JS.FC.>"},
201204
{stream: "deliver.hengli.wsw.>", accounts: ["wsw"]}
202205
]
203206
},
204-
wsw:{
207+
wsw: {
205208
jetstream: enabled
206209
users:[
207210
{user: _wswConnUser_, password: _wswConnUser_},
208211
{user: wsw, password: wsw, permissions: {
209-
publish:{
212+
publish: {
210213
allow:["\$JS.ACK.hengli_to_wsw_test.>"]
211214
},
212-
subscribe:{
215+
subscribe: {
213216
allow:["_recv_wsw.hengli.to.wsw.test"]
214217
}
215218
}}
216219
]
217220
imports:[
218-
{service:{account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
219-
{stream:{account:"hengli", subject:"deliver.hengli.wsw.>"}}
221+
{service: {account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
222+
{service: {account: "hengli", subject: "\$JS.FC.>"}},
223+
{stream: {account:"hengli", subject:"deliver.hengli.wsw.>"}}
220224
]
221225
}
222226
}
@@ -238,33 +242,35 @@ leafnodes: {
238242
port: 24224
239243
server_name: wsw_3
240244
241-
accounts:{
242-
hengli:{
245+
accounts: {
246+
hengli: {
243247
jetstream: enabled
244248
users:[
245249
{user: _hengliConnUser_, password: _hengliConnUser_}
246250
]
247251
exports:[
248252
{service: "\$JS.hengli.API.>", response: stream},
253+
{service: "\$JS.FC.>"},
249254
{stream: "deliver.hengli.wsw.>", accounts: ["wsw"]}
250255
]
251256
},
252-
wsw:{
257+
wsw: {
253258
jetstream: enabled
254259
users:[
255260
{user: _wswConnUser_, password: _wswConnUser_},
256261
{user: wsw, password: wsw, permissions: {
257-
publish:{
262+
publish: {
258263
allow:["\$JS.ACK.hengli_to_wsw_test.>"]
259264
},
260-
subscribe:{
265+
subscribe: {
261266
allow:["_recv_wsw.hengli.to.wsw.test"]
262267
}
263268
}}
264269
]
265270
imports:[
266-
{service:{account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
267-
{stream:{account:"hengli", subject:"deliver.hengli.wsw.>"}}
271+
{service: {account:"hengli", subject: "\$JS.hengli.API.>"}, to: "\$JS.hengli.wsw.API.>"},
272+
{service: {account: "hengli", subject: "\$JS.FC.>"}},
273+
{stream: {account:"hengli", subject:"deliver.hengli.wsw.>"}}
268274
]
269275
}
270276
}
@@ -275,42 +281,42 @@ EOF
275281
# Start a server for each configuration and sleep a second in
276282
# between so the seeds can startup and get healthy.
277283
echo "Starting b_1..."
278-
nats-server -c b_1.conf -P b_1.pid & #> /dev/null 2>&1 &
284+
nats-server -c b_1.conf -P b_1.pid > /dev/null 2>&1 &
279285
sleep 1
280286

281287
echo "Starting b_2..."
282-
nats-server -c b_2.conf -P b_2.pid & #> /dev/null 2>&1 &
288+
nats-server -c b_2.conf -P b_2.pid > /dev/null 2>&1 &
283289
sleep 1
284290

285291
echo "Starting b_3..."
286-
nats-server -c b_3.conf -P b_3.pid & #> /dev/null 2>&1 &
292+
nats-server -c b_3.conf -P b_3.pid > /dev/null 2>&1 &
287293
sleep 1
288294

289295
# Wait until the servers up and healthy.
290296
echo 'Hub cluster healthy?'
291297
curl --fail --silent \
292298
--retry 5 \
293-
--retry-delay 1 \
299+
--retry-delay 2 \
294300
http://localhost:28222/healthz; echo
295301

296302
echo "Starting a_1..."
297-
nats-server -c a_1.conf -P a_1.pid & #> /dev/null 2>&1 &
303+
nats-server -c a_1.conf -P a_1.pid > /dev/null 2>&1 &
298304
sleep 1
299305

300306
echo "Starting a_2..."
301-
nats-server -c a_2.conf -P a_2.pid & #> /dev/null 2>&1 &
307+
nats-server -c a_2.conf -P a_2.pid > /dev/null 2>&1 &
302308
sleep 1
303309

304310
echo "Starting a_3..."
305-
nats-server -c a_3.conf -P a_3.pid & #> /dev/null 2>&1 &
311+
nats-server -c a_3.conf -P a_3.pid > /dev/null 2>&1 &
306312
sleep 1
307313

308314

309315
# Wait until the servers up and healthy.
310316
echo 'Leaf cluster healthy?'
311317
curl --fail --silent \
312318
--retry 5 \
313-
--retry-delay 1 \
319+
--retry-delay 2 \
314320
http://localhost:18222/healthz; echo
315321

316322
cat <<- EOF > origin-stream.json
@@ -399,13 +405,9 @@ nats bench \
399405
--no-progress \
400406
hengli.to.wsw.test
401407

402-
sleep 2
403-
404408
# Report the streams
405409
nats -s "nats://_hengliConnUser_:_hengliConnUser_@127.0.0.1:14222" \
406410
stream report
407411

408-
sleep 2
409-
410412
nats -s "nats://_wswConnUser_:_wswConnUser_@127.0.0.1:24222" \
411413
stream report

0 commit comments

Comments
 (0)