natskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

API

Description

Capability record for the NATS client surface.

Synopsis

Documentation

data Client #

Client capabilities for publishing, subscribing, and lifecycle control.

Constructors

Client 

Fields

data MsgView #

MsgView represents a MSG in the NATS protocol.

Constructors

MsgView 

Fields

Instances

Instances details
Show MsgView # 
Instance details

Defined in API

Eq MsgView # 
Instance details

Defined in API

Methods

(==) :: MsgView -> MsgView -> Bool #

(/=) :: MsgView -> MsgView -> Bool #

type PublishOption = CallOption PublishConfig #

type SubscribeOption = CallOption SubscribeConfig #

withSubscriptionExpiry :: NominalDiffTime -> SubscribeOption #

withSubscriptionExpiry sets the reply subscription expiry in seconds. Default: no expiry (reply subscriptions stay open until unsubscribe).

Examples:

{-# LANGUAGE OverloadedStrings #-}

subscribe client "events.created" [withSubscriptionExpiry 2] print

withPayload :: Payload -> PublishOption #

withPayload is used to set the payload for a publish operation. Default: no payload.

Examples:

{-# LANGUAGE OverloadedStrings #-}

publish client "updates" [withPayload "hello"]

withReplyCallback :: (Maybe MsgView -> IO ()) -> PublishOption #

withReplyCallback is used to set a callback for a reply to a publish operation. Default: no reply subscription; publishes are fire-and-forget.

Examples:

{-# LANGUAGE OverloadedStrings #-}

publish client "service.echo" [withReplyCallback print]

withHeaders :: Headers -> PublishOption #

withHeaders is used to set headers for a publish operation. Default: no headers.

Examples:

{-# LANGUAGE OverloadedStrings #-}

publish client "updates" [withHeaders [("source", "test")]]