nsc

nsc creates NATS operators, accounts, users, and manage their permissions.

create operator

nsc create operator -s # Die -s zorgt voor een GOEIE sys account met juiste 
                       # rechten op streams.

Listing

nsc list operators
nsc list accounts
nsc list users

Set current operator/account

nsc env -o <operator>
nsc env -a <account>

export jwt

nsc describe user -a other -n usr_other -R
nsc describe account --name other -R
nsc describe operator -R

export creds

note: Only users have creds.

nsc generate creds -i
nsc generate creds -a account -n username

export seeds

nsc export keys -a # account
nsc export keys -o # operator

Nats

Environment variables

echo $NATS_CREDS
echo $NATS_URL

request/reply

On the replying side:

nats reply reqrep "pong: {{.Request}}"

On the requesting side:

nats request reqrep hoi

Stream

view msgs in a stream (does not ack)

nats stream view <stream>

Consumers

A "Consumer" provides a stateful view on a stream. Eg. when there are 2 applications accessing a stream, each application can use a consumer to have their own independent view of available messages.