iterator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package iterator implements the CDC and Snapshot iterators for MongoDB. Working with them is carried out through a combined iterator.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoIterator occurs when the [Combined] has no any underlying iterators.
	ErrNoIterator = errors.New("no iterator")
)

Functions

This section is empty.

Types

type Combined

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

Combined is a combined iterator for MongoDB. It consists of the cdc and snapshot iterators. A snapshot is captured only if the snapshot is set to true.

func NewCombined

func NewCombined(ctx context.Context, params CombinedParams) (*Combined, error)

NewCombined creates a new instance of the Combined.

func (*Combined) HasNext

func (c *Combined) HasNext(ctx context.Context) (bool, error)

HasNext returns a bool indicating whether the iterator has the next record to return or not. If the underlying snapshot iterator returns false, the combined iterator will try to switch to the cdc iterator.

func (*Combined) Next

func (c *Combined) Next(ctx context.Context) (sdk.Record, error)

Next returns the next record.

func (*Combined) Stop

func (c *Combined) Stop(ctx context.Context) error

Stop stops the underlying iterators.

type CombinedParams

type CombinedParams struct {
	Collection    *mongo.Collection
	BatchSize     int
	Snapshot      bool
	OrderingField string
	SDKPosition   sdk.Position
}

CombinedParams is an incoming params for the NewCombined function.

Jump to

Keyboard shortcuts

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