iterator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilSDKPosition occurs when trying to parse a nil [sdk.Position].
	// It's just a sentinel error for the [parsePosition] function.
	ErrNilSDKPosition = errors.New("nil sdk position")
)

Functions

This section is empty.

Types

type Position

type Position struct {
	Mode PositionMode `json:"mode"`
	// LastProcessedValue is a value of the last processed element by the snapshot capture.
	// This value is used if the mode is snapshot.
	LastProcessedValue any `json:"lastProcessedValue"`
	// MaxElement is a max value of an ordering property at the start of a snapshot.
	// This value is used if the mode is snapshot.
	MaxElement any `json:"maxElement,omitempty"`
}

Position is an iterator position.

func ParsePosition

func ParsePosition(sdkPosition sdk.Position) (*Position, error)

ParsePosition converts an sdk.Position into a [position].

func (*Position) MarshalSDKPosition

func (p *Position) MarshalSDKPosition() (sdk.Position, error)

MarshalSDKPosition marshals the underlying [position] into a sdk.Position as JSON bytes.

type PositionMode

type PositionMode string

PositionMode defines the [position] mode.

const (
	ModeSnapshot        PositionMode = "snapshot"
	ModeSnapshotPolling PositionMode = "snapshot_polling"
)

The available position modes are listed below.

type Snapshot

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

Snapshot implements a snapshot logic for the connector.

func NewPollingSnapshot

func NewPollingSnapshot(ctx context.Context, params SnapshotParams) (*Snapshot, error)

NewPollingSnapshot creates a new instance of the Snapshot iterator prepared for polling.

func NewSnapshot

func NewSnapshot(ctx context.Context, params SnapshotParams) (*Snapshot, error)

NewSnapshot creates a new instance of the Snapshot.

func (*Snapshot) HasNext

func (s *Snapshot) HasNext(ctx context.Context) (bool, error)

HasNext checks whether the snapshot iterator has records to return or not.

func (*Snapshot) Next

func (s *Snapshot) Next(ctx context.Context) (sdk.Record, error)

Next returns the next available record.

type SnapshotParams

type SnapshotParams struct {
	Driver           neo4j.DriverWithContext
	OrderingProperty string
	KeyProperties    []string
	EntityType       config.EntityType
	EntityLabels     []string
	BatchSize        int
	DatabaseName     string
	Position         *Position
}

SnapshotParams is incoming params for the NewSnapshot function.

Jump to

Keyboard shortcuts

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