Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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) Next ¶
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.