Documentation ¶
Overview ¶
Package transaction provides the transaction on the raw byte data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = fmt.Errorf("transaction: transaction closed")
ErrClosed is the error which returns when tries to access the closed transaction.
ErrUnavailable is the error which returns when tries to accessing the data which is not available.
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 ¶
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 ¶
Commit flushes the snapshot to the original, closes this transaction and frees all resources associated with it. Note that it doesn't check that the original is still available for writing.
func (*Tx) Length ¶
Length returns the length, in bytes, of the data which is available for this transaction.
func (*Tx) Offset ¶
Offset returns the lowest offset from start of the original which is available for this transaction.
func (*Tx) ReadAt ¶
ReadAt reads len(buf) bytes at given offset from start of the original from the snapshot. If the given offset is outside of the accessible range the ErrUnavailable error will be returned. If there are not enough bytes to read then will be read how many there is and the number of read bytes will be returned with the ErrUnavailable error. Otherwise len(buf) will be returned with no errors. ReadAt implements the io.ReaderAt interface.
func (*Tx) WriteAt ¶
WriteAt writes len(buf) bytes at given offset from start of the original into the snapshot. If the given offset is outside of the accessible range the ErrUnavailable error will be returned. If there are not enough space to write all given bytes then will be written as much as possible and the number of written bytes will be returned with the ErrUnavailable error. Otherwise len(buf) will be returned with no errors. WriteAt implements the io.WriterAt interface.