nats-io / Nats.cr
Licence: apache-2.0
Crystal client for NATS
Stars: ✭ 33
Programming Languages
crystal
512 projects
NATS - Crystal Client
Simple NATS client for the Crystal programming language.
Installation
- Add the dependency to your
shard.yml
:
dependencies:
nats:
github: nats-io/nats.cr
- Run
shards install
Usage
require "nats"
nc = NATS::Connection.new("demo.nats.io")
nc.subscribe("foo") { |msg| puts "Received '#{msg}'"}
nc.publish("foo", "Hello!")
sub = nc.subscribe("req") do |msg|
msg.respond("ANSWER is 42")
end
answer = nc.request("req", "Help!")
puts "Received a response '#{answer}'!"
sub.close
nc.close
License
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].