iterator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeSnapshot = "snapshot"
	ModeCDC      = "cdc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CDC

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

CDC represents an implementation of a CDC iterator for Oracle.

func NewCDC

func NewCDC(ctx context.Context, params CDCParams) (*CDC, error)

NewCDC creates a new instance of the CDC iterator.

func (*CDC) Close

func (iter *CDC) Close() (err error)

Close closes database rows of CDC iterator.

func (*CDC) HasNext

func (iter *CDC) HasNext(ctx context.Context) (bool, error)

HasNext returns a bool indicating whether the iterator has the next record to return or not.

func (*CDC) Next

func (iter *CDC) Next(ctx context.Context) (sdk.Record, error)

Next returns the next record.

type CDCParams

type CDCParams struct {
	Repo           *repository.Oracle
	Position       *Position
	Table          string
	TrackingTable  string
	Trigger        string
	OrderingColumn string
	KeyColumns     []string
	Columns        []string
	BatchSize      int
}

CDCParams represents an incoming params for the NewCDC function.

type Iterator

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

Iterator represents an implementation of an iterator for Oracle.

func New

func New(ctx context.Context, params *Params) (*Iterator, error)

New creates a new instance of the iterator.

func (*Iterator) Close

func (iter *Iterator) Close() (err error)

Close stops iterators and closes database connection.

func (*Iterator) HasNext

func (iter *Iterator) HasNext(ctx context.Context) (bool, error)

HasNext returns a bool indicating whether the iterator has the next record to return or not.

func (*Iterator) Next

func (iter *Iterator) Next(ctx context.Context) (sdk.Record, error)

Next returns the next record.

func (*Iterator) PushValueToDelete

func (iter *Iterator) PushValueToDelete(position sdk.Position) error

PushValueToDelete appends the last processed value to the slice to clear the tracking table in the future.

type Mode

type Mode string

Mode defines an iterator mode.

type Params

type Params struct {
	Position *Position
	URL      string
	Table    string

	SnapshotTable string
	TrackingTable string
	Trigger       string

	OrderingColumn string
	KeyColumns     []string
	Snapshot       bool
	Columns        []string

	BatchSize int
}

Params represents an incoming iterator params for the New function.

func NewParams

func NewParams(pos *Position, config config.Source) *Params

type Position

type Position struct {
	// Mode represents current iterator mode.
	Mode Mode `json:"mode"`

	// LastProcessedVal represents the last processed value from ordering column.
	LastProcessedVal any    `json:"last_processed_val"`
	TrackingTable    string `json:"tracking_table"`
	Trigger          string `json:"trigger"`
	SnapshotTable    string `json:"snapshot_table"`
}

Position represents Oracle position.

func ParseSDKPosition

func ParseSDKPosition(position sdk.Position) (*Position, error)

ParseSDKPosition parses sdk.Position and returns Position.

func (Position) ToSDK

func (p Position) ToSDK() (sdk.Position, error)

ToSDK marshals Position and returns sdk.Position or an error.

type Snapshot

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

Snapshot represents an implementation of a Snapshot iterator for Oracle.

func NewSnapshot

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

NewSnapshot creates a new instance of the Snapshot iterator.

func (*Snapshot) Close

func (iter *Snapshot) Close() error

Close closes database rows of Snapshot iterator.

func (*Snapshot) HasNext

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

HasNext returns a bool indicating whether the iterator has the next record to return or not.

func (*Snapshot) Next

func (iter *Snapshot) Next(_ context.Context) (sdk.Record, error)

Next returns the next record.

type SnapshotParams

type SnapshotParams struct {
	Repo           *repository.Oracle
	Position       *Position
	Table          string
	SnapshotTable  string
	TrackingTable  string
	Trigger        string
	OrderingColumn string
	KeyColumns     []string
	Columns        []string
	BatchSize      int
	ColumnTypes    map[string]columntypes.ColumnDescription
}

SnapshotParams represents an incoming params for the NewSnapshot function.

Jump to

Keyboard shortcuts

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