options

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 3 Imported by: 0

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 string
}

func ParseAddStreamOptions

func ParseAddStreamOptions(opts ...AddStream) AddStreamOptions

ParseAddStreamOptions parses the options and returns the add stream options.

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. If the block duration is set to 0 then the reader blocks indefinitely.

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. pattern must be a valid regular expression or NewReader panics.

type ReaderOptions

type ReaderOptions struct {
	BlockDuration time.Duration
	MaxPolled     int64
	Topic         string
	TopicPattern  string
	BufferSize    int
	LastEventID   string
}

func ParseReaderOptions

func ParseReaderOptions(opts ...Reader) ReaderOptions

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

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. 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. If the block duration is set to 0 then the sink blocks indefinitely.

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 removes the need to acknowledge events read from the sink.

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. pattern must be a valid regular expression or NewSink panics.

type SinkOptions

type SinkOptions struct {
	BlockDuration  time.Duration
	MaxPolled      int64
	Topic          string
	TopicPattern   string
	BufferSize     int
	LastEventID    string
	NoAck          bool
	AckGracePeriod time.Duration
}

func ParseSinkOptions

func ParseSinkOptions(opts ...Sink) SinkOptions

ParseSinkOptions parses the options and returns the sink options.

type Stream

type Stream func(*StreamOptions)

Stream is a stream creation 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 maximum number of events stored by the stream.

type StreamOptions

type StreamOptions struct {
	MaxLen int
	Logger pulse.Logger
}

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