db

package
v0.0.0-...-8fcfbba Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

This package defines a SQLCipher database. It provides some default setup options and provides an interface for running functions before and after a transaction.

Index

Constants

View Source
const NullFlag = 1

Variables

This section is empty.

Functions

func EAVExtractNameValues

func EAVExtractNameValues(in []byte) (map[uint32]*EAVValue, error)

func EAVPack

func EAVPack(nameIdx uint32, ts uint64, null bool, val []byte) []byte

Types

type CallbackFunc

type CallbackFunc func(viewName string, phase int, groupID, id []byte) error

type Database

type Database struct {
	Log        *zap.SugaredLogger
	Conn       *sqlx.DB
	Tx         *sqlx.Tx
	EAVHandler *EAV
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(c *config.Config, cl clock.Clock, path string) (*Database, error)

func (*Database) AfterCommit

func (db *Database) AfterCommit(f func())

func (*Database) BeforeCommit

func (db *Database) BeforeCommit(f RunnerFunc)

func (*Database) DB

func (db *Database) DB() *sql.DB

func (*Database) Initialize

func (db *Database) Initialize(key []byte) error

func (*Database) Initialized

func (db *Database) Initialized() bool

func (*Database) Lock

func (db *Database) Lock(label string, runner RunnerFunc) error

func (*Database) Migrate

func (db *Database) Migrate(name string, migrations []*migration.Migration) error

func (*Database) MigrateNoLock

func (db *Database) MigrateNoLock(name string, migrations []*migration.Migration) error

func (*Database) Open

func (db *Database) Open(key []byte) error

func (*Database) Run

func (db *Database) Run(label string, runner RunnerFunc) error

func (*Database) RunReadOnly

func (db *Database) RunReadOnly(label string, runner RunnerFunc) error

func (*Database) RunTx

func (db *Database) RunTx(label string, txOptions *sql.TxOptions, runner RunnerFunc) error

func (*Database) Shutdown

func (db *Database) Shutdown() error

func (*Database) Vacuum

func (db *Database) Vacuum() error

type EAV

type EAV struct {
	Clock clock.Clock
	// contains filtered or unexported fields
}

func (*EAV) MakeEmptyRecord

func (eav *EAV) MakeEmptyRecord() []byte

func (*EAV) MakeRecord

func (eav *EAV) MakeRecord(packed ...[]byte) ([]byte, error)

func (*EAV) SetCallback

func (eav *EAV) SetCallback(r CallbackFunc)

type EAVValue

type EAVValue struct {
	Time uint64
	Flag uint8
	Val  []byte
}

type RunnerFunc

type RunnerFunc func() error

Jump to

Keyboard shortcuts

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