Skip to content

Commit

Permalink
Update to include request-reply example
Browse files Browse the repository at this point in the history
Signed-off-by: Byron Ruth <[email protected]>
  • Loading branch information
bruth committed Dec 5, 2022
1 parent 4487607 commit 39a4509
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions examples/use-cases/cross-leaf-mirror/cli/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ nsc push -a APP
nsc add user --account APP leaf-east \
--allow-sub '$JS.leaf-east.API.CONSUMER.CREATE.events' \
--allow-sub '$JS.leaf-east.API.CONSUMER.CREATE.events.>' \
--allow-pub '$JS.M.*' \
--allow-pub '_GR_.>'
--allow-sub 'leaf-east.>' \
--allow-pub 'leaf-west.events.M.*' \
--allow-pub '_GR_.>' \
--allow-pub '_INBOX_west.>'

# The `leaf-west` user needs to be able to create a consumer (implicitly)
# when the local stream mirror is setup and subscribe to the deliver subject
Expand All @@ -333,7 +335,9 @@ nsc add user --account APP leaf-east \
nsc add user --account APP leaf-west \
--allow-pub '$JS.leaf-east.API.CONSUMER.CREATE.events' \
--allow-pub '$JS.leaf-east.API.CONSUMER.CREATE.events.>' \
--allow-sub '$JS.M.*' \
--allow-pub 'leaf-east.hello' \
--allow-sub '_INBOX_west.>' \
--allow-sub 'leaf-west.events.M.*' \
--allow-sub '$JSC.R.*'

# ### Create the leaf configurations
Expand Down Expand Up @@ -447,7 +451,7 @@ cat <<- EOF > leaf-west-mirror.json
"name": "events",
"external": {
"api": "\$JS.leaf-east.API",
"deliver": ""
"deliver": "leaf-west.events"
}
},
"sealed": false,
Expand All @@ -470,3 +474,16 @@ nats --context leaf-east req 'events.3' ''
# List the streams in both east and west to observe the state.
nats --context leaf-east stream list
nats --context leaf-west stream list

# Start up a reply service in east.
nats --context leaf-east reply \
leaf-east.hello 'hello from leaf-east' &
sleep 1

# Send a request to the `leaf-east.hello` subject
# that only exists in the leaf-east. This also uses an
# inbox-prefix so the pub permission in east can be constrained.
nats --context leaf-west \
--inbox-prefix _INBOX_west \
request leaf-east.hello \
'hi from leaf-west!'

1 comment on commit 39a4509

@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-bhr8bv2dy-connecteverything.vercel.app

Built with commit 39a4509.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.