binmandb

package
v0.11.0 Latest Latest
Warning

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

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

README

binmandb

This package is used by binman for interactions with a bbolt db.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilReadResponse is returned when a read operation  returns nil
	ErrNilReadResponse = errors.New("Read Operation returned nil")
	// ErrKeyExists is returned when trying to update a data key that already has data
	// This will only be returned if overwrite is set to false(the default)
	ErrKeyExists = errors.New("Refusing to overwrite exisitng data key")
)

Functions

func DeleteData

func DeleteData(key string, db *bolt.DB) error

DeleteData will delete either key/values or Buckets depending on what is sent by user

func GetBytes

func GetBytes(i interface{}) []byte

getBytes is a helper function to convert types to byte arrays as needed

func GetDB

func GetDB(dbPath string, o ...bolt.Options) *bolt.DB

func GetData

func GetData(key string, db *bolt.DB) ([]byte, error)

read from db

func ParseKey

func ParseKey(key string) [][]byte

func RunDB

func RunDB(options DbConfig)

RunDB waits for messages on dbChan and performs the appropriate operations

func WriteData

func WriteData(overwrite bool, key string, data []byte, db *bolt.DB) error

write to db

Types

type DBResponse

type DBResponse struct {
	Err  error
	Data []byte
}

type DbConfig

type DbConfig struct {
	Path      string
	Dwg       *sync.WaitGroup
	DbChan    chan DbMsg
	Overwrite bool
}

DbConfig contains required chan/wg + config options

type DbMsg

type DbMsg struct {
	Key        string // "Keys should be in the format key/subkey/subsubkey"
	Data       []byte
	Operation  string // "read/write/delete"
	ReturnChan chan DBResponse
	ReturnWg   *sync.WaitGroup
}

func (*DbMsg) Send added in v0.11.0

func (dbMsg *DbMsg) Send(dbChan chan DbMsg) DBResponse

Jump to

Keyboard shortcuts

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