class

Alumna::Nats::JetStream

Inherits Reference < Object

Constructors

new(client : NATS::Client)
Source

Instance methods

ack(msg : Message) : Nil | Alumna::Nats::Error

Acknowledge the message. The handler does not ack when it returns.

Source
consumer_info(stream : String, name : String) : Consumer | Nil | Alumna::Nats::Error

Return the consumer, or nil if it does not exist.

Source
create_consumer(stream : String, name : String, *, deliver_subject : String | Nil = nil, deliver_group : String | Nil = nil, filter_subject : String | Nil = nil, ack_wait : Time::Span | Nil = nil) : Consumer | Alumna::Nats::Error

Create a durable push consumer. Does not create a stream. Default deliver_group is name so workers on this consumer compete. Default deliver_subject is generated from the stream and consumer names. Deliver policy is all: a late consumer receives stored messages. Optional ack_wait is how long an unacked message waits before redelivery. On a workqueue stream, one consumer per interest. Extra overlapping consumers return Error. Workers share this consumer.

Source
create_stream(name : String, subjects : Array(String), *, storage : Storage = :file, retention : Retention = :limits) : Stream | Alumna::Nats::Error

Create a stream. name must not be empty and must not contain '.'. Default retention is limits. Pass :workqueue for the job queue: the first ack removes the message, and a second consumer on the same interest returns Error.

Source
delete_consumer(stream : String, name : String) : Nil | Alumna::Nats::Error

Remove the consumer. If the consumer does not exist, this is a no-op.

Source
delete_stream(name : String) : Nil | Alumna::Nats::Error

Remove the stream. If the stream does not exist, this is a no-op.

Source
nack(msg : Message, *, delay : Time::Span | Nil = nil) : Nil | Alumna::Nats::Error

Reject the message so the server can deliver it again. delay waits before the next delivery.

Source
publish(subject : String, payload : String | Bytes) : PubAck | Alumna::Nats::Error

Publish to a stream that already listens on subject. If no stream listens, return Error. This does not create a stream.

Source
stream_info(name : String) : Stream | Nil | Alumna::Nats::Error

Return the stream, or nil if it does not exist.

Source
subscribe(consumer : Consumer, &block : Message -> ) : Alumna::Nats::Subscription | Alumna::Nats::Error

Push subscribe. Does not block. Does not create a consumer. Does not ack. consumer must have a deliver subject (push). Pull consumers raise ArgumentError.

Source
unsubscribe(subscription : Alumna::Nats::Subscription) : Nil | Alumna::Nats::Error
Source

Nested types