natskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

API

Description

Capability record for the NATS client surface.

Synopsis

Documentation

data Client Source #

Client capabilities for publishing, subscribing, and lifecycle control.

Constructors

Client 

Fields

data MsgView Source #

MsgView represents a MSG in the NATS protocol.

Constructors

MsgView 

Fields

Instances

Instances details
Show MsgView Source # 
Instance details

Defined in API

Eq MsgView Source # 
Instance details

Defined in API

Methods

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

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

type PublishOption = CallOption PublishConfig Source #

type SubscribeOption = CallOption SubscribeConfig Source #

withSubscriptionExpiry :: NominalDiffTime -> SubscribeOption Source #

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

withQueueGroup :: Subject -> SubscribeOption Source #

withQueueGroup sets the queue group for a subscription. Default: no queue group.

withPayload :: Payload -> PublishOption Source #

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 Source #

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]

withReplyTo :: Subject -> PublishOption Source #

withReplyTo sets an explicit reply subject for a publish operation. Default: no reply subject unless a reply callback is configured.

This option only controls the outgoing reply subject. It does not create a subscription; callers that expect multiple replies should subscribe to the reply subject themselves.

withHeaders :: Headers -> PublishOption Source #

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

Examples:

{-# LANGUAGE OverloadedStrings #-}

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