Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nats-io/nats.cr
Crystal client for NATS
https://github.com/nats-io/nats.cr
Last synced: about 2 months ago
JSON representation
Crystal client for NATS
- Host: GitHub
- URL: https://github.com/nats-io/nats.cr
- Owner: nats-io
- License: apache-2.0
- Created: 2019-08-22T04:17:03.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-07T20:34:11.000Z (over 2 years ago)
- Last Synced: 2024-05-01T21:49:02.432Z (5 months ago)
- Language: Crystal
- Size: 67.4 KB
- Stars: 44
- Watchers: 3
- Forks: 12
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - NATS.io - NATS client (Queues and Messaging)
- awesome-crystal - NATS.io - NATS client (Queues and Messaging)
README
# NATS - Crystal Client
Simple NATS client for the [Crystal](https://crystal-lang.org) programming language.
[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.org/nats-io/nats.cr.svg?branch=master)](http://travis-ci.org/nats-io/nats.cr)## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
nats:
github: nats-io/nats.cr
```2. Run `shards install`
## Usage
```crystal
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")
endanswer = 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.