Project

nats-async

0.0
No release in over 3 years
Lightweight async Ruby connector for NATS
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.10
~> 1.12
~> 0.6.0
~> 2.14.2

Runtime

~> 2.36
~> 0.3
~> 1.34
~> 0.11
>= 0.1, < 1.0
 Project Readme

Nats Async

nats-async packages the nats-test prototype as a Ruby gem that uses gem async.

Installation

Add the gem to your bundle:

gem "nats-async"

Or install it directly:

gem install nats-async

Usage

require "nats-async"

connector = NatsAsync::SimpleConnector.new(url: "nats://127.0.0.1:4222", verbose: false)
connector.run(duration: 1) do |client, task|
  client.subscribe("demo.subject") do |message|
    puts "received: #{message.data}"
    task.stop
  end

  client.publish("demo.subject", "hello")
end

Examples

Core pub/sub:

bundle exec ruby examples/basic_pub_sub.rb

JetStream publish and pull:

bundle exec ruby examples/jetstream_roundtrip.rb

The integration spec boots the bundled bin/nats-server and runs these examples locally.

Development

bundle install
bundle exec rspec
rake build