Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zaben903/nats.cr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NATS - Crystal Client

Simple NATS client for the Crystal programming language.

License Apache 2 Build Status

Installation

  1. Add the dependency to your shard.yml:
   dependencies:
     nats:
       github: nats-io/nats.cr
  1. Run shards install

Usage

require "nats/client"

client = NATS::Client.new("nats://localhost:4222")
client.connect

client.subscribe("foo") do |msg|
  puts "Received message on subject #{msg.subject}: #{msg.payload}"
end

client.publish("foo", "Hello, NATS!")

client.subscribe("bar") do |msg|
  msg.reply "Received your message on bar: #{msg.payload}"
end

response = client.request("bar", "Hello, bar!")
puts "Received response: #{response.payload}"

client.request("bar") do |msg|
  puts "Recieved async response: #{msg.payload}"
end

client.close

License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

About

Crystal client for NATS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Crystal 98.8%
  • Shell 1.2%