longpoll

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRows is returned when there are no rows to read.
	// * This can happen if the database is closed early, if there are no
	// rows in the result set, or if there are no results left to return.
	ErrNoRows = fmt.Errorf("no more rows")
	// ErrSnapshotInterrupt is returned when Teardown or any other signal
	// cancels an in-progress snapshot.
	ErrSnapshotInterrupt = fmt.Errorf("interrupted snapshot")
)

Functions

This section is empty.

Types

type SnapshotIterator

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

SnapshotIterator implements the Iterator interface for capturing an initial table snapshot.

func NewSnapshotIterator

func NewSnapshotIterator(ctx context.Context, conn *pgx.Conn, table string, columns []string, key string) (*SnapshotIterator, error)

NewSnapshotIterator returns a SnapshotIterator that is an Iterator. * NewSnapshotIterator attempts to load the sql rows into the SnapshotIterator and will immediately begin to return them to subsequent Read calls. * It acquires a read only transaction lock before reading the table. * If Teardown is called while a snapshot is in progress, it will return an ErrSnapshotInterrupt error.

func (*SnapshotIterator) Ack

Ack is here to implement the Iterator interface, it does nothing.

func (*SnapshotIterator) Next

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

Next returns the next row in the iterators rows. * If Next is called after HasNext has returned false, it will return an ErrNoRows error.

func (*SnapshotIterator) Teardown

func (s *SnapshotIterator) Teardown(_ context.Context) error

Teardown cleans up the database iterator by committing and closing the connection to sql.Rows * If the snapshot is not complete yet, it will return an ErrSnpashotInterrupt * Teardown must be called by the caller, it will not automatically be called when the snapshot is completed. * Teardown handles all of its manual cleanup first then calls cancel to stop any unhandled contexts that we've received.

Jump to

Keyboard shortcuts

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