options

package
v1.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 3 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddEvent

type AddEvent func(*AddEventOptions)

AddEvent is an option for adding an event to a stream.

func WithOnlyIfStreamExists

func WithOnlyIfStreamExists() AddEvent

WithOnlyIfStreamExists only adds the event if the stream exists.

func WithTopic

func WithTopic(topic string) AddEvent

WithTopic sets the topic for the added event.

type AddEventOptions

type AddEventOptions struct {
	Topic              string
	OnlyIfStreamExists bool
}

func ParseAddEventOptions

func ParseAddEventOptions(opts ...AddEvent) AddEventOptions

ParseAddEventOptions parses the given options and returns the corresponding AddEventOptions.

type AddStream

type AddStream func(*AddStreamOptions)

AddStream is an option for adding a stream to a sink.

func WithAddStreamStartAfter

func WithAddStreamStartAfter(id string) AddStream

WithAddStreamStartAfter sets the last read event ID, the sink will start reading from the next event. Only one of WithAddStreamStartAtNewest, WithAddStreamStartAtOldest, WithAddStreamStartAfter or WithAddStreamStartAt can be used.

func WithAddStreamStartAt

func WithAddStreamStartAt(startAt time.Time) AddStream

WithAddStreamStartAt sets the start position for the added stream to the event added on or after startAt. Only one of WithAddStreamStartAtNewest, WithAddStreamStartAtOldest, WithAddStreamStartAfter or WithAddStreamStartAt can be used.

func WithAddStreamStartAtNewest

func WithAddStreamStartAtNewest() AddStream

WithAddStreamStartAtNewest sets the sink start position for the added stream to the newest event. Only one of WithAddStreamStartAtNewest, WithAddStreamStartAtOldest, WithAddStreamStartAfter or WithAddStreamStartAt can be used.

func WithAddStreamStartAtOldest

func WithAddStreamStartAtOldest() AddStream

WithAddStreamStartAtOldest sets the sink start position for the added stream to the oldest event. Only one of WithAddStreamStartAtNewest, WithAddStreamStartAtOldest, WithAddStreamStartAfter or WithAddStreamStartAt can be used.

type AddStreamOptions

type AddStreamOptions struct {
	// LastEventID is the ID after which delivery starts for this stream.
	LastEventID string
	// contains filtered or unexported fields
}

AddStreamOptions keeps its v1 field first; new fields are only ever appended so existing keyed construction remains source-compatible.

func ParseAddStreamOptions

func ParseAddStreamOptions(opts ...AddStream) AddStreamOptions

ParseAddStreamOptions parses the options and returns the add stream options.

func (AddStreamOptions) HasConflictingStartOptions added in v1.10.0

func (o AddStreamOptions) HasConflictingStartOptions() bool

HasConflictingStartOptions reports whether more than one cursor-start option was supplied. AddStream rejects this instead of silently accepting the last option.

type Reader

type Reader func(*ReaderOptions)

Reader is a sink creation option.

func WithReaderBlockDuration

func WithReaderBlockDuration(d time.Duration) Reader

WithReaderBlockDuration sets the maximum amount of time the reader waits for MaxPolled events. The default block duration is 5 seconds. NewReader rejects durations below one millisecond because Redis block timing is millisecond precision and every read must have a finite shutdown bound.

func WithReaderBufferSize

func WithReaderBufferSize(size int) Reader

WithReaderBufferSize sets the reader channel buffer size. The default buffer size is 1000. If the buffer is full the reader blocks until the buffer has space available.

func WithReaderMaxPolled

func WithReaderMaxPolled(n int64) Reader

WithReaderMaxPolled sets the maximum number of events polled by the reader at once. The default maximum number of events is 1000.

func WithReaderStartAfter

func WithReaderStartAfter(id string) Reader

WithReaderStartAfter sets the last read event ID, the reader will start reading from the next event.

func WithReaderStartAt

func WithReaderStartAt(startAt time.Time) Reader

WithReaderStartAt sets the start position for the reader to the event added on or after startAt.

func WithReaderStartAtNewest

func WithReaderStartAtNewest() Reader

WithReaderStartAtNewest sets the reader start position to the newest event, this is the default. Only one of WithReaderStartAtNewest, WithReaderStartAtOldest, WithReaderStartAfter or WithReaderStartAt can be used.

func WithReaderStartAtOldest

func WithReaderStartAtOldest() Reader

WithReaderStartAtOldest sets the reader start position to the oldest event. Only one of WithReaderStartAtOldest, WithReaderStartAfter or WithReaderStartAt should be used.

func WithReaderTopic

func WithReaderTopic(topic string) Reader

WithReaderTopic sets the reader topic.

func WithReaderTopicPattern

func WithReaderTopicPattern(pattern string) Reader

WithReaderTopicPattern sets the reader topic pattern. NewReader returns an error when pattern is not a valid regular expression.

type ReaderOptions

type ReaderOptions struct {
	// BlockDuration is the XREAD block duration.
	BlockDuration time.Duration
	// MaxPolled is the maximum number of events read per XREAD call.
	MaxPolled int64
	// Topic delivers only events published with this exact topic.
	Topic string
	// TopicPattern delivers only events whose topic matches this regex.
	TopicPattern string
	// BufferSize is the capacity of each subscription channel.
	BufferSize int
	// LastEventID is the ID after which delivery starts.
	LastEventID string
	// contains filtered or unexported fields
}

ReaderOptions keeps its v1 fields first, in v1 order; new fields are only ever appended so existing keyed construction and field access remain source-compatible across feature releases.

func ParseReaderOptions

func ParseReaderOptions(opts ...Reader) ReaderOptions

ParseReaderOptions parses the given options and returns the corresponding reader options.

func (ReaderOptions) HasConflictingStartOptions added in v1.10.0

func (o ReaderOptions) HasConflictingStartOptions() bool

HasConflictingStartOptions reports whether more than one cursor-start option was supplied. Constructors reject this instead of silently accepting the last option.

type Sink

type Sink func(*SinkOptions)

Sink is a sink creation option.

func WithSinkAckGracePeriod

func WithSinkAckGracePeriod(d time.Duration) Sink

WithSinkAckGracePeriod sets the grace period for acknowledging events. The default grace period is 20 seconds; NewSink rejects values below one millisecond. Note: all sinks with identical names must have the same ack grace period.

func WithSinkBlockDuration

func WithSinkBlockDuration(d time.Duration) Sink

WithSinkBlockDuration sets the maximum amount of time the sink waits for MaxPolled events. The default block duration is 5 seconds. NewSink rejects durations below one millisecond because Redis block timing is millisecond precision and every read must have a finite shutdown bound.

func WithSinkBufferSize

func WithSinkBufferSize(size int) Sink

WithSinkBufferSize sets the sink channel buffer size. The default buffer size is 1000. If the buffer is full the sink blocks until the buffer has space available.

func WithSinkMaxPolled

func WithSinkMaxPolled(n int64) Sink

WithSinkMaxPolled sets the maximum number of events polled by the sink at once. The default maximum number of events is 1000.

func WithSinkNoAck

func WithSinkNoAck() Sink

WithSinkNoAck atomically acknowledges each event before delivering it to subscribers, preserving at-most-once delivery without requiring Sink.Ack.

func WithSinkStartAfter

func WithSinkStartAfter(id string) Sink

WithSinkStartAfter sets the last read event ID, the sink will start reading from the next event. Only one of WithSinkStartAtNewest, WithSinkStartAtOldest, WithSinkStartAfter or WithSinkStartAt can be used.

func WithSinkStartAt

func WithSinkStartAt(startAt time.Time) Sink

WithSinkStartAt sets the start position for the sink, defaults to the last event. Only one of WithSinkStartAtNewest, WithSinkStartAtOldest, WithSinkStartAfter or WithSinkStartAt can be used.

func WithSinkStartAtNewest

func WithSinkStartAtNewest() Sink

WithSinkStartAtNewest sets the sink start position to the newest event, this is the default. Only one of WithSinkStartAtNewest, WithSinkStartAtOldest, WithSinkStartAfter or WithSinkStartAt can be used.

func WithSinkStartAtOldest

func WithSinkStartAtOldest() Sink

WithSinkStartAtOldest sets the sink start position to the oldest event. Only one of WithSinkStartAtNewest, WithSinkStartAtOldest, WithSinkStartAfter or WithSinkStartAt can be used.

func WithSinkTopic

func WithSinkTopic(topic string) Sink

WithSinkTopic sets the sink topic.

func WithSinkTopicPattern

func WithSinkTopicPattern(pattern string) Sink

WithSinkTopicPattern sets the sink topic pattern. NewSink returns an error when pattern is not a valid regular expression.

type SinkOptions

type SinkOptions struct {
	// BlockDuration is the XREADGROUP block duration.
	BlockDuration time.Duration
	// MaxPolled is the maximum number of events read per XREADGROUP call.
	MaxPolled int64
	// Topic delivers only events published with this exact topic.
	Topic string
	// TopicPattern delivers only events whose topic matches this regex.
	TopicPattern string
	// BufferSize is the capacity of each subscription channel.
	BufferSize int
	// LastEventID is the ID after which delivery starts.
	LastEventID string
	// NoAck atomically acknowledges each event before delivery.
	NoAck bool
	// AckGracePeriod bounds how long an unacknowledged event stays owned
	// by one consumer before stale recovery may reclaim it.
	AckGracePeriod time.Duration
	// contains filtered or unexported fields
}

SinkOptions keeps its v1 fields first, in v1 order; new fields are only ever appended so existing keyed construction and field access remain source-compatible across feature releases.

func ParseSinkOptions

func ParseSinkOptions(opts ...Sink) SinkOptions

ParseSinkOptions parses the options and returns the sink options.

func (SinkOptions) HasConflictingStartOptions added in v1.10.0

func (o SinkOptions) HasConflictingStartOptions() bool

HasConflictingStartOptions reports whether more than one cursor-start option was supplied. Constructors reject this instead of silently accepting the last option.

type Stream

type Stream func(*StreamOptions)

Stream is a stream creation option.

func WithStreamDeadline added in v1.10.0

func WithStreamDeadline(deadline time.Time) Stream

WithStreamDeadline makes the stream generation expire at deadline. The deadline is persisted when the handle first opens; handles for the same generation must not request a different deadline. TTL options cannot be combined with this option.

func WithStreamLogger

func WithStreamLogger(logger pulse.Logger) Stream

WithStreamLogger sets the logger used by the stream.

func WithStreamMaxLen

func WithStreamMaxLen(len int) Stream

WithStreamMaxLen sets the positive maximum number of events stored by the stream. NewStream rejects zero and negative values.

func WithStreamSlidingTTL added in v1.5.0

func WithStreamSlidingTTL(ttl time.Duration) Stream

WithStreamSlidingTTL sets a sliding TTL on the Redis key backing the stream. The TTL is refreshed on every published event; NewStream rejects values below Redis's one-millisecond precision.

func WithStreamTTL added in v1.5.0

func WithStreamTTL(ttl time.Duration) Stream

WithStreamTTL sets an absolute TTL on the Redis key backing the stream. The TTL is set once and never extended; NewStream rejects values below Redis's one-millisecond precision.

func WithUnboundedStream added in v1.10.0

func WithUnboundedStream() Stream

WithUnboundedStream disables MAXLEN trimming. Callers must remove settled events explicitly. It cannot be combined with WithStreamMaxLen.

type StreamOptions

type StreamOptions struct {
	MaxLen int
	Logger pulse.Logger
	// TTL configures a retention window for the Redis key backing the stream.
	// When zero, no TTL is applied.
	TTL time.Duration
	// TTLSliding controls whether the TTL is refreshed on every published event.
	// When false, the TTL is applied once (absolute TTL) and never extended.
	TTLSliding bool

	// MaxLenSet distinguishes an omitted MaxLen from an explicit request.
	MaxLenSet bool
	// Unbounded disables MAXLEN trimming entirely.
	Unbounded bool
	// TTLSet distinguishes an omitted TTL from an explicitly invalid zero.
	TTLSet bool
	// Deadline is the immutable absolute expiry claimed by this stream
	// generation when DeadlineSet is true.
	Deadline time.Time
	// DeadlineSet distinguishes an omitted deadline from the zero time.
	DeadlineSet bool
}

StreamOptions keeps its v1 fields first, in v1 order; new fields are only ever appended so existing keyed construction and field access remain source-compatible across feature releases.

func ParseStreamOptions

func ParseStreamOptions(opts ...Stream) StreamOptions

ParseStreamOptions parses the given options and returns the corresponding StreamOptions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL