boltdblib

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(path string) (*bolt.DB, error)

func TxFromContext added in v1.5.2

func TxFromContext(ctx context.Context) (*bolt.Tx, bool)

TxFromContext retrieves the transaction from the context, if available.

func Update added in v1.5.2

func Update(ctx context.Context, db *bolt.DB, update func(tx *bolt.Tx) error) error

Update is a helper function that will update the job in the store it accepts a context, an update function and creates a new transaction to perform the update if no transaction is provided in the context

func View added in v1.5.2

func View(ctx context.Context, db *bolt.DB, view func(tx *bolt.Tx) error) error

View is a helper function that will perform a read-only operation on the store it accepts a context, a view function and creates a new transaction to perform the view if no transaction is provided in the context

Types

type TracingContext added in v1.5.2

type TracingContext struct {
	TxContext
	// contains filtered or unexported fields
}

TracingContext is a context that can be used to trace the duration of a transaction and log a debug message if it exceeds a certain threshold.

func NewTracingContext added in v1.5.2

func NewTracingContext(ctx TxContext) *TracingContext

NewTracingContext creates a new tracing context

func (*TracingContext) Commit added in v1.5.2

func (t *TracingContext) Commit() error

func (*TracingContext) Rollback added in v1.5.2

func (t *TracingContext) Rollback() error

func (*TracingContext) WithTracingDuration added in v1.5.2

func (t *TracingContext) WithTracingDuration(d time.Duration) *TracingContext

WithTracingDuration sets the duration threshold for transaction tracing

type TxContext added in v1.5.2

type TxContext interface {
	context.Context
	Commit() error
	Rollback() error
}

TxContext is a transactional context that can be used to commit or rollback

func NewTxContext added in v1.5.2

func NewTxContext(ctx context.Context, tx *bolt.Tx) TxContext

NewTxContext creates a new transactional context for a BoltDB transaction. It embeds a standard context and manages transaction commit/rollback based on the context's lifecycle.

Jump to

Keyboard shortcuts

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