Skip to content

derekcollison/nats.cr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 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"

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.flush
nc.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.2%
  • Shell 1.8%