NATS client for Julia.
This client is feature complete in terms of Core NATS
protocol and most of JetStream API.
- All
NATS
authentication methods - TLS support
- Zero copy protocol parser
Performance is matching reference go
implementation.
It was tested in julia
1.9
and 1.10
It was tested on NATS
2.10
.
Start nats-server:
docker run -p 4222:4222 nats:latest
julia> using NATS
julia> nc = NATS.connect()
NATS.Connection(my_cluster cluster, CONNECTED, 0 subs, 0 unsubs)
julia> sub = subscribe(nc, "test_subject") do msg
@show payload(msg)
end;
julia> publish(nc, "test_subject", "Hello.")
payload(msg) = "Hello."
julia> drain(nc, sub)
> nats reply help.please 'OK, I CAN HELP!!!'
20:35:19 Listening on "help.please" in group "NATS-RPLY-22"
julia> using NATS
julia> nc = NATS.connect()
NATS.Connection(my_cluster cluster, CONNECTED, 0 subs, 0 unsubs)
julia> rep = @time NATS.request(nc, "help.please");
0.003854 seconds (177 allocations: 76.359 KiB)
julia> payload(rep)
"OK, I CAN HELP!!!"
julia> using NATS
julia> nc = NATS.connect()
NATS.Connection(my_cluster cluster, CONNECTED, 0 subs, 0 unsubs)
julia> sub = reply(nc, "some.service") do msg
"This is response"
end
julia> rep = @time NATS.request(nc, "some.service");
0.002897 seconds (231 allocations: 143.078 KiB)
julia> payload(rep)
"This is response"
julia> drain(nc, sub)