struct
NATS::JetStream::Streams
- NATS::JetStream::Streams
- Struct
- Value
- Object
Overview
A stream in NATS JetStream represents the history of messages pertaining to a given domain. When you publish a message to a subject that a stream is monitoring, the stream then adds that message to its history in the order it was published.
Defined in:
jetstream/streams.crConstructors
Instance Method Summary
- #create(config : StreamConfig) : Stream
-
#create(storage : StreamConfig::Storage, retention : StreamConfig::RetentionPolicy | Nil = nil, discard : StreamConfig::DiscardPolicy | Nil = nil, compression : StreamConfig::Compression = :none, persist_mode : StreamConfig::PersistMode | Nil = nil, **kwargs) : Stream
Create a stream of the given storage type and with the given properties, which are passed unmodified to
NATS::JetStream::StreamConfig.new. -
#delete(stream : JetStream::Stream)
Delete the given stream
-
#delete(stream : String)
Delete the stream with the given name
-
#direct_get(stream : String, *, last_by_subject : String) : JetStream::StreamGetMsgResponse | Nil
The
#get_msgAPI involves some administrative overhead and usually routes to the stream's primary node in the NATS cluster. -
#direct_get(stream : String, *, sequence : Int, next_by_subject : String | Nil = nil)
The
#get_msgAPI involves some administrative overhead and usually routes to the stream's primary node in the NATS cluster. - #get_msg(stream : String, *, last_by_subject : String)
- #get_msg(stream : String, *, sequence : Int, next_by_subject : String | Nil = nil)
-
#info(name : String) : Stream | Nil
Get the current state of the stream with the given
name -
#list(subject : String | Nil = nil, offset : Int | Nil = nil, limit : Int | Nil = nil)
List all available streams
- #purge(stream : String, subject : String) : Int64
-
#update(config : StreamConfig) : Stream
Update an existing stream with the given config.
-
#update(name : String, **changes) : Stream
Change the given settings on the stream with the given
name, leaving all of its other settings as they are.
Constructor Detail
Instance Method Detail
Create a stream of the given storage type and with the given
properties, which are passed unmodified to
NATS::JetStream::StreamConfig.new.
The #get_msg API involves some administrative overhead and usually routes
to the stream's primary node in the NATS cluster. The #direct_get method
uses the DIRECT.GET API which allows any server hosting the stream
(including replicas) to respond with the message data. Specifying
last_by_subject allows you to get the last message in a stream that was
published to a specific subject. This is used by NATS::KV internally to
fetch values for a given key from replicas for the KV's backing stream.
NOTE In order to use this API, the stream must have been created with
allow_direct
set to true. For performance reasons, the client does not perform this
check.
The #get_msg API involves some administrative overhead and usually routes
to the stream's primary node in the NATS cluster. The #direct_get method
uses the DIRECT.GET API which allows any server hosting the stream
(including replicas) to respond with the message data. Specifying
last_by_subject allows you to get the last message in a stream that was
published to a specific subject. This is used by NATS::KV internally to
fetch values for a given key from replicas for the KV's backing stream.
NOTE In order to use this API, the stream must have been created with
allow_direct
set to true. For performance reasons, the client does not perform this
check.
Get the current state of the stream with the given name
List all available streams
Update an existing stream with the given config. The server replaces the
stream's entire config, so any settings not in config are reset to
their defaults. To change only some settings, use the
update(name, **changes) overload instead.
Change the given settings on the stream with the given name, leaving
all of its other settings as they are. The setting names are the same
as the properties on NATS::JetStream::StreamConfig.
jetstream.stream.update "orders", max_age: 7.days