Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wallyqs/racket-nats
A NATS client for Racket
https://github.com/wallyqs/racket-nats
Last synced: 8 days ago
JSON representation
A NATS client for Racket
- Host: GitHub
- URL: https://github.com/wallyqs/racket-nats
- Owner: wallyqs
- Created: 2015-04-21T15:43:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-18T20:16:50.000Z (over 8 years ago)
- Last Synced: 2024-11-04T23:24:05.681Z (about 2 months ago)
- Language: Racket
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.org
Awesome Lists containing this project
README
# -*- mode: org; mode: auto-fill -*-
#+TITLE: NATS Client for Racket
#+startup: showeverything
#+todo: todo:t*status*: alpha, still a work in progress
This is a very simple implementation of a NATS client for Racket
at the moment, implementation would change a lot.*** Usage
Currently basic subscriptions and publishing of messages work as follows:
#+BEGIN_SRC racket
#lang racket(require "../nats.rkt")
(define worker-response "{\"result\":~a}~n")
(define nats-io (nats-connect #:host "127.0.0.1" #:port 4222))(printf "Subscribing to 'workers.double ~n")
(nats-sub "workers.double"
(lambda (msg)
(define result (* 2 (string->number (bytes->string/utf-8 msg))))
(nats-pub "workers.results" (format worker-response result) nats-io)) nats-io)
#+END_SRC*** To do
- [ ] Implement inboxes for the request pattern
- [ ] Reconnect and graceful failures
- [ ] Convert into a module
- [ ] Logging facilities
- [ ] Add testing framework
- [ ] Cluster mode
- [X] Authentication*** License
#+BEGIN_SRC racket :tangle nats.rkt
;;
;; (The MIT License)
;;
;; Copyright (c) 2015 Waldemar Quevedo. All rights reserved.
;;
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;
#+END_SRC