iterator

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextItemInSliceStreams

func NextItemInSliceStreams(ctx context.Context, streamSlices []*Stream, streamToProcess []int) (string, error)

NextItemInSliceStreams will advance all streamSlices specified in streamToProcess and return the item advanced. Assumption is that the stream slices first item is identical, and we want to advance all these streams.

Types

type Msg

type Msg struct {
	Iter storage.Iterator[string]
	Err  error
}

type Stream

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

Stream aggregates multiple iterators that are sent to a source channel into one iterator.

func NewStream

func NewStream(idx int, source chan *Msg) *Stream

func (*Stream) Drain

func (s *Stream) Drain(ctx context.Context) ([]string, error)

Drain all item in the stream's buffer and return these items.

func (*Stream) Head

func (s *Stream) Head(ctx context.Context) (string, error)

Head returns the first item in the buffer. If the Head is sourceIsClosed or cancelled, it will stop the buffer and set the buffer to nil.

func (*Stream) Idx

func (s *Stream) Idx() int

func (*Stream) Next

func (s *Stream) Next(ctx context.Context) (string, error)

func (*Stream) SkipToTargetObject

func (s *Stream) SkipToTargetObject(ctx context.Context, target string) error

SkipToTargetObject moves the buffer until the buffer's head object is >= target object. If the buffer is drained and no more items, it will set to stop and buffer will be nil.

func (*Stream) Stop

func (s *Stream) Stop()

type Streams

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

func NewStreams

func NewStreams(streams []*Stream) *Streams

func (*Streams) CleanDone

func (s *Streams) CleanDone(ctx context.Context) ([]*Stream, error)

CleanDone will clean up the sourceIsClosed iterator streams and return a list of the remaining active streams. To be considered active your source channel must still be open.

func (*Streams) GetActiveStreamsCount

func (s *Streams) GetActiveStreamsCount() int

GetActiveStreamsCount will return the active streams from the last time CleanDone was called.

func (*Streams) Stop

func (s *Streams) Stop()

Stop will Drain all streams completely to avoid leaving dangling resources NOTE: caller should consider running this in a goroutine to not block.

Jump to

Keyboard shortcuts

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