Popularity
6.7
Stable
Activity
0.0
Stable
19
3
5
Monthly Downloads: 5
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags:
Network
Latest version: v0.1.2.1
nats-queue alternatives and similar packages
Based on the "Networking" category.
Alternatively, view nats-queue alternatives based on common mentions on social networks and blogs.
-
call-haskell-from-anything
Call Haskell functions from any programming language via serialization and dynamic libraries -
PortFusion
Haskell-powered cross-platform transport-layer distributed reverse / forward proxy & tunneling solution – currently available for all TCP protocols (RDP, VNC, HTTP(S), SSH, ...). -
ngx-export
A comprehensive web framework aimed at building custom Haskell handlers for the Nginx Web Server
InfluxDB - Purpose built for real-time analytics at any scale.
InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
Promo
www.influxdata.com
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of nats-queue or a related project?
README
NATS - Haskell client
Haskell API for NATS messaging system (see https://github.com/derekcollison/nats).
- Network failures/reconnections are handled automatically in the background,
however
subscribe
andrequest
functions can still return a network exception. - It should correctly combine with
System.Timeout
, therefore there is no API for timeouts as in other language API. - There is no automatic unsubscribe after certain number of messages as this is easily handled by other means.
- The functions
unsubscribe
andpublish
will not fail. They may take up to 1 second if there is a problem with network connection. They will not block and not throw an exception if the client is disconnected from the server. (NATS does not guarantee delivery anyway) - Clustered NATS is supported. NATS servers can be specified by overriding defaultSettings. Upon failure, the background thread automatically reconnects to the next available server. Rejected connections and unresponsive servers are handled by closing current connection and trying next server (the timeout is 1 second).
Example use:
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as BL
import Network.Nats
import Control.Concurrent
main :: IO ()
main = do
-- Connect to the NATS server
nats <- connect "nats://user:password@localhost:4222"
-- Subscribe to channel "news", we do not use any queue group
sid <- subscribe nats "news" Nothing $
\_ _ msg _ -> -- The parameters are (sid, subject, message, reply_subject)
putStrLn $ show msg
-- Publish a message (the message parameter is a lazy ByteString)
publish nats "news" "I got news for you"
-- Wait so that we can receive the message from the server
threadDelay 1000000
-- Unsubscribe from the channel
unsubscribe nats sid
-- Subscribe to a "gift" channel
subscribe nats "gift" Nothing $ \_ _ msg mreply -> do
putStrLn $ show msg
case mreply of -- If the sender used a 'request' call, use this subject to send message back
Nothing -> return ()
Just reply -> publish nats reply "I've got a gift for you."
-- Request/response communication with a "gift" channel
reply <- request nats "gift" "Do you have anything for me?"
putStrLn $ show reply