transaction

package
v0.0.0-...-5b112dc Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = fmt.Errorf("transaction: transaction closed")
View Source
var ErrOutOfBounds = fmt.Errorf("transaction: out of bounds")

Functions

This section is empty.

Types

type Tx

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

Tx is a transaction on the raw byte data.

func Begin

func Begin(data []byte, offset int64, length uintptr) (*Tx, error)

Begin starts and returns a new transaction. The given raw byte data starting from the given offset and ends after the given length copies to the snapshot which is allocated into the heap.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit flushes the snapshot to the original, closes this transaction and frees all resources associated with it.

func (*Tx) ReadAt

func (tx *Tx) ReadAt(buf []byte, offset int64) (int, error)

ReadAt reads len(buf) bytes at given offset from start of the original from the snapshot. If the given offset is out of the available bounds or there are not enough bytes to read the ErrOutOfBounds error will be returned. Otherwise len(buf) will be returned with no errors. ReadAt implements the io.ReaderAt interface.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback closes this transaction and frees all resources associated with it.

func (*Tx) Segment

func (tx *Tx) Segment() *segment.Segment

Segment returns the data segment on top of the snapshot.

func (*Tx) WriteAt

func (tx *Tx) WriteAt(buf []byte, offset int64) (int, error)

WriteAt writes len(buf) bytes at given offset from start of the original into the snapshot. If the given offset is out of the available bounds or there are not enough space to write all given bytes the ErrOutOfBounds error will be returned. Otherwise len(buf) will be returned with no errors. WriteAt implements the io.WriterAt interface.

Jump to

Keyboard shortcuts

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