Documentation
¶
Overview ¶
Package jsm provides client helpers for managing and interacting with NATS JetStream
Index ¶
- Variables
- func BackupJetStreamConfiguration(backupDir string, data bool) error
- func Connect(servers string, opts ...nats.Option) (err error)
- func Connection() *nats.Conn
- func ConsumerNames(stream string, opts ...RequestOption) (names []string, err error)
- func EachStream(cb func(*Stream), opts ...RequestOption) (err error)
- func EachStreamTemplate(cb func(*StreamTemplate), opts ...RequestOption) (err error)
- func Flush() error
- func IsErrorResponse(m *nats.Msg) bool
- func IsJetStreamEnabled(opts ...RequestOption) bool
- func IsKnownConsumer(stream string, consumer string, opts ...RequestOption) (bool, error)
- func IsKnownStream(stream string, opts ...RequestOption) (bool, error)
- func IsKnownStreamTemplate(template string, opts ...RequestOption) (bool, error)
- func IsOKResponse(m *nats.Msg) bool
- func IsValidName(n string) bool
- func JetStreamAccountInfo(opts ...RequestOption) (info *api.JetStreamAccountStats, err error)
- func NextMsg(stream string, consumer string, opts ...RequestOption) (msgs *nats.Msg, err error)
- func NextSubject(stream string, consumer string) (string, error)
- func NoTrace()
- func NoValidate()
- func ParseErrorResponse(m *nats.Msg) error
- func ParseEvent(e []byte) (schema string, event interface{}, err error)
- func RestoreJetStreamConfiguration(backupDir string, update bool) error
- func RestoreJetStreamConfigurationFile(path string, update bool) error
- func SetConnection(c *nats.Conn)
- func SetTimeout(t time.Duration)
- func StreamNames(opts ...RequestOption) (names []string, err error)
- func StreamTemplateNames(opts ...RequestOption) (templates []string, err error)
- func Trace()
- func Validate()
- type BackupData
- type Consumer
- func Consumers(stream string, opts ...RequestOption) (consumers []*Consumer, err error)
- func LoadConsumer(stream string, name string, opts ...RequestOption) (consumer *Consumer, err error)
- func LoadOrNewConsumer(stream string, name string, opts ...ConsumerOption) (consumer *Consumer, err error)
- func LoadOrNewConsumerFromDefault(stream string, name string, template api.ConsumerConfig, ...) (consumer *Consumer, err error)
- func NewConsumer(stream string, opts ...ConsumerOption) (consumer *Consumer, err error)
- func NewConsumerFromDefault(stream string, dflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
- func (c *Consumer) AckPolicy() api.AckPolicy
- func (c *Consumer) AckSampleSubject() string
- func (c *Consumer) AckWait() time.Duration
- func (c *Consumer) AcknowledgedFloor(opts ...RequestOption) (stats api.SequencePair, err error)
- func (c *Consumer) AdvisorySubject() string
- func (c *Consumer) ChanQueueSubscribe(group string, ch chan *nats.Msg) (sub *nats.Subscription, err error)
- func (c *Consumer) ChanSubscribe(ch chan *nats.Msg) (sub *nats.Subscription, err error)
- func (c *Consumer) Configuration() (config api.ConsumerConfig)
- func (c *Consumer) Delete() (err error)
- func (c *Consumer) DeliverPolicy() api.DeliverPolicy
- func (c *Consumer) DeliveredState(opts ...RequestOption) (stats api.SequencePair, err error)
- func (c *Consumer) DeliverySubject() string
- func (c *Consumer) DurableName() string
- func (c *Consumer) FilterSubject() string
- func (c *Consumer) IsDurable() bool
- func (c *Consumer) IsEphemeral() bool
- func (c *Consumer) IsPullMode() bool
- func (c *Consumer) IsPushMode() bool
- func (c *Consumer) IsSampled() bool
- func (c *Consumer) MaxDeliver() int
- func (c *Consumer) MetricSubject() string
- func (c *Consumer) Name() string
- func (c *Consumer) NextMsg(opts ...RequestOption) (m *nats.Msg, err error)
- func (c *Consumer) NextSubject() string
- func (c *Consumer) PendingMessageCount(opts ...RequestOption) (int, error)
- func (c *Consumer) QueueSubscribe(queue string, h func(*nats.Msg)) (sub *nats.Subscription, err error)
- func (c *Consumer) QueueSubscribeSync(queue string) (sub *nats.Subscription, err error)
- func (c *Consumer) QueueSubscribeSyncWithChan(queue string, ch chan *nats.Msg) (sub *nats.Subscription, err error)
- func (c *Consumer) RateLimit() uint64
- func (c *Consumer) RedeliveryCount(opts ...RequestOption) (int, error)
- func (c *Consumer) ReplayPolicy() api.ReplayPolicy
- func (c *Consumer) Reset(opts ...RequestOption) error
- func (c *Consumer) SampleFrequency() string
- func (c *Consumer) StartSequence() uint64
- func (c *Consumer) StartTime() time.Time
- func (c *Consumer) State(opts ...RequestOption) (api.ConsumerInfo, error)
- func (c *Consumer) StreamName() string
- func (c *Consumer) Subscribe(h func(*nats.Msg)) (sub *nats.Subscription, err error)
- func (c *Consumer) SubscribeSync() (sub *nats.Subscription, err error)
- type ConsumerBackup
- type ConsumerCfg
- type ConsumerOption
- func AckWait(t time.Duration) ConsumerOption
- func AcknowledgeAll() ConsumerOption
- func AcknowledgeExplicit() ConsumerOption
- func AcknowledgeNone() ConsumerOption
- func ConsumerConnection(opts ...RequestOption) ConsumerOption
- func DeliverAllAvailable() ConsumerOption
- func DeliverySubject(s string) ConsumerOption
- func DurableName(s string) ConsumerOption
- func FilterStreamBySubject(s string) ConsumerOption
- func MaxDeliveryAttempts(n int) ConsumerOption
- func RateLimitBitsPerSecond(bps uint64) ConsumerOption
- func ReplayAsReceived() ConsumerOption
- func ReplayInstantly() ConsumerOption
- func SamplePercent(i int) ConsumerOption
- func StartAtSequence(s uint64) ConsumerOption
- func StartAtTime(t time.Time) ConsumerOption
- func StartAtTimeDelta(d time.Duration) ConsumerOption
- func StartWithLastReceived() ConsumerOption
- func StartWithNextReceived() ConsumerOption
- type MsgInfo
- type RequestOption
- type RestoreProgress
- type SnapshotOption
- func RestoreNotify(cb func(RestoreProgress)) SnapshotOption
- func SnapshotChunkSize(sz int) SnapshotOption
- func SnapshotConnection(opts ...RequestOption) SnapshotOption
- func SnapshotConsumers() SnapshotOption
- func SnapshotDebug() SnapshotOption
- func SnapshotHealthCheck() SnapshotOption
- func SnapshotNotify(cb func(SnapshotProgress)) SnapshotOption
- type SnapshotProgress
- type Stream
- func LoadOrNewStream(name string, opts ...StreamOption) (stream *Stream, err error)
- func LoadOrNewStreamFromDefault(name string, dflt api.StreamConfig, opts ...StreamOption) (stream *Stream, err error)
- func LoadStream(name string, opts ...RequestOption) (stream *Stream, err error)
- func NewStream(name string, opts ...StreamOption) (stream *Stream, err error)
- func NewStreamFromDefault(name string, dflt api.StreamConfig, opts ...StreamOption) (stream *Stream, err error)
- func Streams(opts ...RequestOption) (streams []*Stream, err error)
- func (s *Stream) AdvisorySubject() string
- func (s *Stream) Configuration() api.StreamConfig
- func (s *Stream) ConsumerNames() (names []string, err error)
- func (s *Stream) Delete() error
- func (s *Stream) DeleteMessage(seq int) (err error)
- func (s *Stream) DuplicateWindow() time.Duration
- func (s *Stream) EachConsumer(cb func(consumer *Consumer)) error
- func (s *Stream) Information() (info *api.StreamInfo, err error)
- func (s *Stream) IsTemplateManaged() bool
- func (s *Stream) LatestInformation() (info *api.StreamInfo, err error)
- func (s *Stream) LatestState() (state api.StreamState, err error)
- func (s *Stream) LoadConsumer(name string) (*Consumer, error)
- func (s *Stream) LoadOrNewConsumer(name string, opts ...ConsumerOption) (consumer *Consumer, err error)
- func (s *Stream) LoadOrNewConsumerFromDefault(name string, deflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
- func (s *Stream) MaxAge() time.Duration
- func (s *Stream) MaxBytes() int64
- func (s *Stream) MaxConsumers() int
- func (s *Stream) MaxMsgSize() int32
- func (s *Stream) MaxMsgs() int64
- func (s *Stream) MetricSubject() string
- func (s *Stream) Name() string
- func (s *Stream) NewConsumer(opts ...ConsumerOption) (consumer *Consumer, err error)
- func (s *Stream) NewConsumerFromDefault(dflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
- func (s *Stream) NoAck() bool
- func (s *Stream) Purge() error
- func (s *Stream) ReadMessage(seq int) (msg *api.StoredMsg, err error)
- func (s *Stream) Replicas() int
- func (s *Stream) Reset() error
- func (s *Stream) Retention() api.RetentionPolicy
- func (s *Stream) SnapshotToFile(ctx context.Context, file string, opts ...SnapshotOption) (SnapshotProgress, error)
- func (s *Stream) State() (stats api.StreamState, err error)
- func (s *Stream) Storage() api.StorageType
- func (s *Stream) Subjects() []string
- func (s *Stream) Template() string
- func (s *Stream) UpdateConfiguration(cfg api.StreamConfig, opts ...StreamOption) error
- type StreamConfig
- type StreamOption
- func DiscardNew() StreamOption
- func DiscardOld() StreamOption
- func DuplicateWindow(d time.Duration) StreamOption
- func FileStorage() StreamOption
- func InterestRetention() StreamOption
- func LimitsRetention() StreamOption
- func MaxAge(m time.Duration) StreamOption
- func MaxBytes(m int64) StreamOption
- func MaxConsumers(m int) StreamOption
- func MaxMessageSize(m int32) StreamOption
- func MaxMessages(m int64) StreamOption
- func MemoryStorage() StreamOption
- func NoAck() StreamOption
- func Replicas(r int) StreamOption
- func StreamConnection(opts ...RequestOption) StreamOption
- func Subjects(s ...string) StreamOption
- func WorkQueueRetention() StreamOption
- type StreamTemplate
- func LoadOrNewStreamTemplate(name string, maxStreams uint32, config api.StreamConfig, opts ...StreamOption) (template *StreamTemplate, err error)
- func LoadStreamTemplate(name string, opts ...RequestOption) (template *StreamTemplate, err error)
- func NewStreamTemplate(name string, maxStreams uint32, config api.StreamConfig, opts ...StreamOption) (template *StreamTemplate, err error)
- func (t *StreamTemplate) Configuration() api.StreamTemplateConfig
- func (t *StreamTemplate) Delete() error
- func (t *StreamTemplate) MaxStreams() uint32
- func (t *StreamTemplate) Name() string
- func (t *StreamTemplate) Reset() error
- func (t *StreamTemplate) StreamConfiguration() api.StreamConfig
- func (t *StreamTemplate) Streams() []string
- type StreamTemplateConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultConsumer = api.ConsumerConfig{ DeliverPolicy: api.DeliverAll, AckPolicy: api.AckExplicit, AckWait: 30 * time.Second, ReplayPolicy: api.ReplayInstant, }
DefaultConsumer is the configuration that will be used to create new Consumers in NewConsumer
var DefaultStream = api.StreamConfig{ Retention: api.LimitsPolicy, Discard: api.DiscardOld, MaxConsumers: -1, MaxMsgs: -1, MaxBytes: -1, MaxAge: 24 * 365 * time.Hour, MaxMsgSize: -1, Replicas: 1, NoAck: false, }
DefaultStream is a template configuration with StreamPolicy retention and 1 years maximum age. No storage type or subjects are set
var DefaultStreamConfiguration = DefaultStream
DefaultStreamConfiguration is the configuration that will be used to create new Streams in NewStream
var DefaultWorkQueue = api.StreamConfig{ Retention: api.WorkQueuePolicy, Discard: api.DiscardOld, MaxConsumers: -1, MaxMsgs: -1, MaxBytes: -1, MaxAge: 24 * 365 * time.Hour, MaxMsgSize: -1, Replicas: 1, NoAck: false, }
DefaultWorkQueue is a template configuration with WorkQueuePolicy retention and 1 years maximum age. No storage type or subjects are set
var SampledDefaultConsumer = api.ConsumerConfig{ DeliverPolicy: api.DeliverAll, AckPolicy: api.AckExplicit, AckWait: 30 * time.Second, ReplayPolicy: api.ReplayInstant, SampleFrequency: "100%", }
SampledDefaultConsumer is the configuration that will be used to create new Consumers in NewConsumer
Functions ¶
func BackupJetStreamConfiguration ¶
BackupJetStreamConfiguration creates a backup of all configuration for Streams, Consumers and Stream Templates.
Stream data can optionally be backed up
func Connect ¶
Connect connects to NATS and configures it to use the connection in future interactions with JetStream Deprecated: Use Request Options to supply the connection
func Connection ¶
Connection is the active NATS connection being used Deprecated: Use Request Options to supply the connection
func ConsumerNames ¶
func ConsumerNames(stream string, opts ...RequestOption) (names []string, err error)
StreamNames is a sorted list of all known consumers within a stream
func EachStream ¶
func EachStream(cb func(*Stream), opts ...RequestOption) (err error)
EachStream iterates over all known Streams
func EachStreamTemplate ¶
func EachStreamTemplate(cb func(*StreamTemplate), opts ...RequestOption) (err error)
EachStreamTemplate iterates over all known Stream Templates
func Flush ¶
func Flush() error
Flush flushes the underlying NATS connection Deprecated: Use Request Options to supply the connection
func IsErrorResponse ¶
IsErrorResponse checks if the message holds a standard JetStream error TODO: parse for error response
func IsJetStreamEnabled ¶
func IsJetStreamEnabled(opts ...RequestOption) bool
IsJetStreamEnabled determines if JetStream is enabled for the current account
func IsKnownConsumer ¶
func IsKnownConsumer(stream string, consumer string, opts ...RequestOption) (bool, error)
IsKnownConsumer determines if a Consumer is known for a specific Stream
func IsKnownStream ¶
func IsKnownStream(stream string, opts ...RequestOption) (bool, error)
IsKnownStream determines if a Stream is known
func IsKnownStreamTemplate ¶
func IsKnownStreamTemplate(template string, opts ...RequestOption) (bool, error)
IsKnownStreamTemplate determines if a StreamTemplate is known
func IsOKResponse ¶
IsOKResponse checks if the message holds a standard JetStream error TODO: parse json responses
func IsValidName ¶ added in v0.0.18
IsValidName verifies if n is a valid stream, template or consumer name
func JetStreamAccountInfo ¶
func JetStreamAccountInfo(opts ...RequestOption) (info *api.JetStreamAccountStats, err error)
JetStreamAccountInfo retrieves information about the current account limits and more
func NextSubject ¶
NextSubject returns the subject used to retrieve the next message for pull-based Consumers, empty when not a pull-base consumer
func ParseErrorResponse ¶
ParseErrorResponse parses the JetStream response, if it's an error returns an error instance holding the message else nil TODO: parse json error response
func ParseEvent ¶
ParseMessage parses event e and returns event as for example *api.ConsumerAckMetric, all unknown event schemas will be of type *UnknownMessage
func RestoreJetStreamConfiguration ¶
RestoreJetStreamConfiguration restores the configuration from a backup made by BackupJetStreamConfiguration
func RestoreJetStreamConfigurationFile ¶
RestoreJetStreamConfigurationFile restores a single file from a backup made by BackupJetStreamConfiguration
func SetConnection ¶
SetConnection sets the connection used to perform requests. Will force using old style requests. Deprecated: Use Request Options to supply the connection
func SetTimeout ¶
SetTimeout sets the timeout for requests to JetStream Deprecated: Use Request Options to supply the timeout
func StreamNames ¶
func StreamNames(opts ...RequestOption) (names []string, err error)
StreamNames is a sorted list of all known Streams
func StreamTemplateNames ¶
func StreamTemplateNames(opts ...RequestOption) (templates []string, err error)
StreamTemplateNames is a sorted list of all known StreamTemplates
Types ¶
type BackupData ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer represents a JetStream consumer
func Consumers ¶
func Consumers(stream string, opts ...RequestOption) (consumers []*Consumer, err error)
Consumers is a sorted list of all known Consumers within a Stream
func LoadConsumer ¶
func LoadConsumer(stream string, name string, opts ...RequestOption) (consumer *Consumer, err error)
LoadConsumer loads a consumer by name
func LoadOrNewConsumer ¶
func LoadOrNewConsumer(stream string, name string, opts ...ConsumerOption) (consumer *Consumer, err error)
LoadOrNewConsumer loads a consumer by name if known else creates a new one with these properties
func LoadOrNewConsumerFromDefault ¶
func LoadOrNewConsumerFromDefault(stream string, name string, template api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
LoadOrNewConsumerFromDefault loads a consumer by name if known else creates a new one with these properties based on template
func NewConsumer ¶
func NewConsumer(stream string, opts ...ConsumerOption) (consumer *Consumer, err error)
NewConsumer creates a consumer based on DefaultConsumer modified by opts
func NewConsumerFromDefault ¶
func NewConsumerFromDefault(stream string, dflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
NewConsumerFromDefault creates a new consumer based on a template config that gets modified by opts
func (*Consumer) AckSampleSubject ¶
AckSampleSubject is the subject used to publish ack samples to
func (*Consumer) AcknowledgedFloor ¶
func (c *Consumer) AcknowledgedFloor(opts ...RequestOption) (stats api.SequencePair, err error)
AcknowledgedFloor reports the highest contiguous message sequences that were acknowledged
func (*Consumer) AdvisorySubject ¶
AdvisorySubject is a wildcard subscription subject that subscribes to all advisories for this consumer
func (*Consumer) ChanQueueSubscribe ¶
func (c *Consumer) ChanQueueSubscribe(group string, ch chan *nats.Msg) (sub *nats.Subscription, err error)
ChanQueueSubscribe see nats.ChanQueueSubscribe Deprecated: use core nats feature
func (*Consumer) ChanSubscribe ¶
ChanSubscribe see nats.ChangSubscribe Deprecated: use core nats feature
func (*Consumer) Configuration ¶
func (c *Consumer) Configuration() (config api.ConsumerConfig)
Configuration is the Consumer configuration
func (*Consumer) Delete ¶
Delete deletes the Consumer, after this the Consumer object should be disposed
func (*Consumer) DeliverPolicy ¶
func (c *Consumer) DeliverPolicy() api.DeliverPolicy
func (*Consumer) DeliveredState ¶
func (c *Consumer) DeliveredState(opts ...RequestOption) (stats api.SequencePair, err error)
DeliveredState reports the messages sequences that were successfully delivered
func (*Consumer) DeliverySubject ¶
func (*Consumer) DurableName ¶
func (*Consumer) FilterSubject ¶
func (*Consumer) IsEphemeral ¶
func (*Consumer) IsPullMode ¶
func (*Consumer) IsPushMode ¶
func (*Consumer) MaxDeliver ¶
func (*Consumer) MetricSubject ¶
MetricSubject is a wildcard subscription subject that subscribes to all metrics for this consumer
func (*Consumer) NextMsg ¶
func (c *Consumer) NextMsg(opts ...RequestOption) (m *nats.Msg, err error)
NextMsg retrieves the next message
func (*Consumer) NextSubject ¶
NextSubject returns the subject used to retrieve the next message for pull-based Consumers, empty when not a pull-base consumer
func (*Consumer) PendingMessageCount ¶
func (c *Consumer) PendingMessageCount(opts ...RequestOption) (int, error)
PendingMessageCount reports the number of messages sent but not yet acknowledged
func (*Consumer) QueueSubscribe ¶
func (c *Consumer) QueueSubscribe(queue string, h func(*nats.Msg)) (sub *nats.Subscription, err error)
QueueSubscribe see nats.QueueSubscribe Deprecated: use core nats feature
func (*Consumer) QueueSubscribeSync ¶
func (c *Consumer) QueueSubscribeSync(queue string) (sub *nats.Subscription, err error)
QueueSubscribeSync see nats.QueueSubscribeSync Deprecated: use core nats feature
func (*Consumer) QueueSubscribeSyncWithChan ¶
func (c *Consumer) QueueSubscribeSyncWithChan(queue string, ch chan *nats.Msg) (sub *nats.Subscription, err error)
QueueSubscribeSyncWithChan see nats.QueueSubscribeSyncWithChan Deprecated: use core nats feature
func (*Consumer) RedeliveryCount ¶
func (c *Consumer) RedeliveryCount(opts ...RequestOption) (int, error)
RedeliveryCount reports the number of redelivers that were done
func (*Consumer) ReplayPolicy ¶
func (c *Consumer) ReplayPolicy() api.ReplayPolicy
func (*Consumer) Reset ¶
func (c *Consumer) Reset(opts ...RequestOption) error
Reset reloads the Consumer configuration from the JetStream server
func (*Consumer) SampleFrequency ¶
func (*Consumer) StartSequence ¶
func (*Consumer) State ¶
func (c *Consumer) State(opts ...RequestOption) (api.ConsumerInfo, error)
State loads a snapshot of consumer state including delivery counts, retries and more
func (*Consumer) StreamName ¶
func (*Consumer) SubscribeSync ¶
func (c *Consumer) SubscribeSync() (sub *nats.Subscription, err error)
SubscribeSync see nats.SubscribeSync Deprecated: use core nats feature
type ConsumerBackup ¶
type ConsumerBackup struct {
Name string `json:"name"`
Stream string `json:"stream"`
Config api.ConsumerConfig `json:"config"`
}
type ConsumerCfg ¶
type ConsumerCfg struct {
api.ConsumerConfig
// contains filtered or unexported fields
}
func NewConsumerConfiguration ¶
func NewConsumerConfiguration(dflt api.ConsumerConfig, opts ...ConsumerOption) (*ConsumerCfg, error)
NewConsumerConfiguration generates a new configuration based on template modified by opts
type ConsumerOption ¶
type ConsumerOption func(o *ConsumerCfg) error
ConsumerOptions configures consumers
func AckWait ¶
func AckWait(t time.Duration) ConsumerOption
func AcknowledgeAll ¶
func AcknowledgeAll() ConsumerOption
func AcknowledgeExplicit ¶
func AcknowledgeExplicit() ConsumerOption
func AcknowledgeNone ¶
func AcknowledgeNone() ConsumerOption
func ConsumerConnection ¶
func ConsumerConnection(opts ...RequestOption) ConsumerOption
func DeliverAllAvailable ¶
func DeliverAllAvailable() ConsumerOption
func DeliverySubject ¶
func DeliverySubject(s string) ConsumerOption
func DurableName ¶
func DurableName(s string) ConsumerOption
func FilterStreamBySubject ¶
func FilterStreamBySubject(s string) ConsumerOption
func MaxDeliveryAttempts ¶
func MaxDeliveryAttempts(n int) ConsumerOption
func RateLimitBitsPerSecond ¶ added in v0.0.18
func RateLimitBitsPerSecond(bps uint64) ConsumerOption
func ReplayAsReceived ¶
func ReplayAsReceived() ConsumerOption
func ReplayInstantly ¶
func ReplayInstantly() ConsumerOption
func SamplePercent ¶
func SamplePercent(i int) ConsumerOption
func StartAtSequence ¶
func StartAtSequence(s uint64) ConsumerOption
func StartAtTime ¶
func StartAtTime(t time.Time) ConsumerOption
func StartAtTimeDelta ¶
func StartAtTimeDelta(d time.Duration) ConsumerOption
func StartWithLastReceived ¶
func StartWithLastReceived() ConsumerOption
func StartWithNextReceived ¶
func StartWithNextReceived() ConsumerOption
type MsgInfo ¶
type MsgInfo struct {
// contains filtered or unexported fields
}
MsgInfo holds metadata about a message that was received from JetStream
func ParseJSMsgMetadata ¶
ParseJSMsgMetadata parse the reply subject metadata to determine message metadata
func (*MsgInfo) ConsumerSequence ¶
func (*MsgInfo) StreamSequence ¶
type RequestOption ¶
type RequestOption func(o *reqoptions)
RequestOption is a option to configure the NATS related options
func WithAPIValidation ¶
func WithAPIValidation() RequestOption
WithAPIValidation validates responses sent from the NATS server against a schema
func WithConnection ¶
func WithConnection(nc *nats.Conn) RequestOption
WithConnection sets the connection to use
func WithContext ¶
func WithContext(ctx context.Context) RequestOption
WithContext sets a context to use for a specific request
func WithTimeout ¶
func WithTimeout(t time.Duration) RequestOption
WithTimeout sets a timeout for the requests
func WithTrace ¶
func WithTrace() RequestOption
WithTrace enables logging of JSON API requests and responses
type RestoreProgress ¶
type RestoreProgress interface {
// StartTime is when the process started
StartTime() time.Time
// EndTime is when the process ended - zero when not completed
EndTime() time.Time
// ChunkSize is the size of the data packets sent over NATS
ChunkSize() int
// ChunksSent is the number of chunks of size ChunkSize that was sent
ChunksSent() uint32
// ChunksToSend number of chunks of ChunkSize expected to be sent
ChunksToSend() int
// BytesSent is the number of bytes sent so far
BytesSent() uint64
// BytesPerSecond is the number of bytes received in the last second, 0 during the first second
BytesPerSecond() uint64
}
func RestoreSnapshotFromFile ¶
func RestoreSnapshotFromFile(ctx context.Context, stream string, file string, opts ...SnapshotOption) (RestoreProgress, *api.StreamState, error)
type SnapshotOption ¶
type SnapshotOption func(o *snapshotOptions)
func RestoreNotify ¶
func RestoreNotify(cb func(RestoreProgress)) SnapshotOption
RestoreNotify notifies cb about progress of the restore operation
func SnapshotChunkSize ¶
func SnapshotChunkSize(sz int) SnapshotOption
SnapshotChunkSize sets the size of data chunks to retrieve
func SnapshotConnection ¶
func SnapshotConnection(opts ...RequestOption) SnapshotOption
SnapshotConnection sets the connection properties to use during snapshot
func SnapshotConsumers ¶
func SnapshotConsumers() SnapshotOption
SnapshotConsumers includes consumer configuration and state in backups
func SnapshotDebug ¶
func SnapshotDebug() SnapshotOption
SnapshotDebug enables logging using the standard go logging library
func SnapshotHealthCheck ¶
func SnapshotHealthCheck() SnapshotOption
SnapshotHealthCheck performs a health check prior to starting the snapshot
func SnapshotNotify ¶
func SnapshotNotify(cb func(SnapshotProgress)) SnapshotOption
SnapshotNotify notifies cb about progress of the snapshot operation
type SnapshotProgress ¶
type SnapshotProgress interface {
// StartTime is when the process started
StartTime() time.Time
// EndTime is when the process ended - zero when not completed
EndTime() time.Time
// ChunkSize is the size of the data packets sent over NATS
ChunkSize() int
// ChunksReceived is how many chunks of ChunkSize were received
ChunksReceived() uint32
// BytesReceived is how many Bytes have been received
BytesReceived() uint64
// BlocksReceived is how many data storage Blocks have been received
BlocksReceived() int
// BlockSize is the size in bytes of each data storage Block
BlockSize() int
// BlocksExpected is the number of blocks expected to be received
BlocksExpected() int
// BlockBytesReceived is the size of uncompressed block data received
BlockBytesReceived() uint64
// HasMetadata indicates if the metadata blocks have been received yet
HasMetadata() bool
// HasData indicates if all the data blocks have been received
HasData() bool
// BytesPerSecond is the number of bytes received in the last second, 0 during the first second
BytesPerSecond() uint64
// HealthCheck indicates if health checking was requested
HealthCheck() bool
}
type Stream ¶
Stream represents a JetStream Stream
func LoadOrNewStream ¶
func LoadOrNewStream(name string, opts ...StreamOption) (stream *Stream, err error)
LoadOrNewStreamFromDefault loads an existing stream or creates a new one matching opts
func LoadOrNewStreamFromDefault ¶
func LoadOrNewStreamFromDefault(name string, dflt api.StreamConfig, opts ...StreamOption) (stream *Stream, err error)
LoadOrNewStreamFromDefault loads an existing stream or creates a new one matching opts and template
func LoadStream ¶
func LoadStream(name string, opts ...RequestOption) (stream *Stream, err error)
LoadStream loads a stream by name
func NewStream ¶
func NewStream(name string, opts ...StreamOption) (stream *Stream, err error)
NewStream creates a new stream using DefaultStream as a starting template allowing adjustments to be made using options
func NewStreamFromDefault ¶
func NewStreamFromDefault(name string, dflt api.StreamConfig, opts ...StreamOption) (stream *Stream, err error)
NewStreamFromDefault creates a new stream based on a supplied template and options
func Streams ¶
func Streams(opts ...RequestOption) (streams []*Stream, err error)
Streams is a sorted list of all known Streams
func (*Stream) AdvisorySubject ¶
AdvisorySubject is a wildcard subscription subject that subscribes to all advisories for this stream
func (*Stream) Configuration ¶
func (s *Stream) Configuration() api.StreamConfig
func (*Stream) ConsumerNames ¶
ConsumerNames is a list of all known consumers for this Stream
func (*Stream) DeleteMessage ¶
DeleteMessage deletes a specific message from the Stream by overwriting it with random data
func (*Stream) DuplicateWindow ¶ added in v0.0.18
func (*Stream) EachConsumer ¶
EachConsumer calls cb with each known consumer for this stream, error on any error to load consumers
func (*Stream) Information ¶
func (s *Stream) Information() (info *api.StreamInfo, err error)
Information loads the current stream information
func (*Stream) IsTemplateManaged ¶
IsTemplateManaged determines if this stream is managed by a template
func (*Stream) LatestInformation ¶
func (s *Stream) LatestInformation() (info *api.StreamInfo, err error)
LatestInformation returns the most recently fetched stream information
func (*Stream) LatestState ¶
func (s *Stream) LatestState() (state api.StreamState, err error)
LatestState returns the most recently fetched stream state
func (*Stream) LoadConsumer ¶
LoadConsumer loads a named consumer related to this Stream
func (*Stream) LoadOrNewConsumer ¶
func (s *Stream) LoadOrNewConsumer(name string, opts ...ConsumerOption) (consumer *Consumer, err error)
LoadOrNewConsumer loads or creates a consumer based on these options
func (*Stream) LoadOrNewConsumerFromDefault ¶
func (s *Stream) LoadOrNewConsumerFromDefault(name string, deflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
LoadOrNewConsumer loads or creates a consumer based on these options that adjust supplied template
func (*Stream) MaxConsumers ¶
func (*Stream) MaxMsgSize ¶
func (*Stream) MetricSubject ¶
MetricSubject is a wildcard subscription subject that subscribes to all advisories for this stream
func (*Stream) NewConsumer ¶
func (s *Stream) NewConsumer(opts ...ConsumerOption) (consumer *Consumer, err error)
NewConsumer creates a new consumer in this Stream based on DefaultConsumer
func (*Stream) NewConsumerFromDefault ¶
func (s *Stream) NewConsumerFromDefault(dflt api.ConsumerConfig, opts ...ConsumerOption) (consumer *Consumer, err error)
NewConsumerFromDefault creates a new consumer in this Stream based on a supplied template config
func (*Stream) ReadMessage ¶
ReadMessage loads a message from the stream by its sequence number
func (*Stream) Retention ¶
func (s *Stream) Retention() api.RetentionPolicy
func (*Stream) SnapshotToFile ¶
func (s *Stream) SnapshotToFile(ctx context.Context, file string, opts ...SnapshotOption) (SnapshotProgress, error)
SnapshotToFile creates a backup into gzipped tar file
func (*Stream) State ¶
func (s *Stream) State() (stats api.StreamState, err error)
State retrieves the Stream State
func (*Stream) Storage ¶
func (s *Stream) Storage() api.StorageType
func (*Stream) UpdateConfiguration ¶
func (s *Stream) UpdateConfiguration(cfg api.StreamConfig, opts ...StreamOption) error
UpdateConfiguration updates the stream using cfg modified by opts, reloads configuration from the server post update
type StreamConfig ¶
type StreamConfig struct {
api.StreamConfig
// contains filtered or unexported fields
}
func NewStreamConfiguration ¶
func NewStreamConfiguration(template api.StreamConfig, opts ...StreamOption) (*StreamConfig, error)
NewStreamConfiguration generates a new configuration based on template modified by opts
type StreamOption ¶
type StreamOption func(o *StreamConfig) error
StreamOption configures a stream
func DiscardNew ¶
func DiscardNew() StreamOption
func DiscardOld ¶
func DiscardOld() StreamOption
func DuplicateWindow ¶ added in v0.0.18
func DuplicateWindow(d time.Duration) StreamOption
func FileStorage ¶
func FileStorage() StreamOption
func InterestRetention ¶
func InterestRetention() StreamOption
func LimitsRetention ¶
func LimitsRetention() StreamOption
func MaxAge ¶
func MaxAge(m time.Duration) StreamOption
func MaxBytes ¶
func MaxBytes(m int64) StreamOption
func MaxConsumers ¶
func MaxConsumers(m int) StreamOption
func MaxMessageSize ¶
func MaxMessageSize(m int32) StreamOption
func MaxMessages ¶
func MaxMessages(m int64) StreamOption
func MemoryStorage ¶
func MemoryStorage() StreamOption
func NoAck ¶
func NoAck() StreamOption
func Replicas ¶
func Replicas(r int) StreamOption
func StreamConnection ¶
func StreamConnection(opts ...RequestOption) StreamOption
func Subjects ¶
func Subjects(s ...string) StreamOption
func WorkQueueRetention ¶
func WorkQueueRetention() StreamOption
type StreamTemplate ¶
type StreamTemplate struct {
// contains filtered or unexported fields
}
func LoadOrNewStreamTemplate ¶
func LoadOrNewStreamTemplate(name string, maxStreams uint32, config api.StreamConfig, opts ...StreamOption) (template *StreamTemplate, err error)
LoadOrNewStreamTemplate loads an existing template, else creates a new one based on config
func LoadStreamTemplate ¶
func LoadStreamTemplate(name string, opts ...RequestOption) (template *StreamTemplate, err error)
LoadStreamTemplate loads a given stream template from JetStream
func NewStreamTemplate ¶
func NewStreamTemplate(name string, maxStreams uint32, config api.StreamConfig, opts ...StreamOption) (template *StreamTemplate, err error)
NewStreamTemplate creates a new template
func (*StreamTemplate) Configuration ¶
func (t *StreamTemplate) Configuration() api.StreamTemplateConfig
func (*StreamTemplate) Delete ¶
func (t *StreamTemplate) Delete() error
Delete deletes the StreamTemplate, after this the StreamTemplate object should be disposed
func (*StreamTemplate) MaxStreams ¶
func (t *StreamTemplate) MaxStreams() uint32
func (*StreamTemplate) Name ¶
func (t *StreamTemplate) Name() string
func (*StreamTemplate) Reset ¶
func (t *StreamTemplate) Reset() error
Reset reloads the Stream Template configuration and state from the JetStream server
func (*StreamTemplate) StreamConfiguration ¶
func (t *StreamTemplate) StreamConfiguration() api.StreamConfig
func (*StreamTemplate) Streams ¶
func (t *StreamTemplate) Streams() []string
type StreamTemplateConfig ¶
type StreamTemplateConfig struct {
api.StreamTemplateConfig
// contains filtered or unexported fields
}