iterator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSubIterator

type PubSubIterator struct {
	// contains filtered or unexported fields
}

func NewPubSubIterator

func NewPubSubIterator(ctx context.Context, client redis.Conn, key string) (*PubSubIterator, error)

NewPubSubIterator creates a new instance of redis pubsub iterator and starts listening for new messages on channel

func (*PubSubIterator) HasNext

func (i *PubSubIterator) HasNext() bool

HasNext returns whether there are any more records to be returned or when the error is to be returned by the Next function

func (*PubSubIterator) Next

func (i *PubSubIterator) Next(ctx context.Context) (sdk.Record, error)

Next pops and returns the first message from records queue

func (*PubSubIterator) Stop

func (i *PubSubIterator) Stop() error

Stop sends a kill signal to tomb, converting the tomb status to Dying giving go routines time to gracefully stop execution

type StreamIterator

type StreamIterator struct {
	// contains filtered or unexported fields
}

func NewStreamIterator

func NewStreamIterator(ctx context.Context,
	client redis.Conn,
	key string,
	pollingInterval time.Duration,
	position sdk.Position,
) (*StreamIterator, error)

NewStreamIterator creates a new instance of redis stream iterator and starts polling redis stream for new changes using the last record id of last successful row read, in a separate go routine

func (*StreamIterator) HasNext

func (i *StreamIterator) HasNext() bool

HasNext returns whether there are any more records to be returned

func (*StreamIterator) Next

func (i *StreamIterator) Next(ctx context.Context) (sdk.Record, error)

Next returns the next record in buffer and error in case there are no more records and there was an error leading to tomb dying or context was cancelled

func (*StreamIterator) Stop

func (i *StreamIterator) Stop() error

Stop stops the go routines

Jump to

Keyboard shortcuts

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