boltdbclient

package module
v0.0.0-...-e76f0cb Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: MIT Imports: 6 Imported by: 0

README

Simple BoltDB Client

Build Status Coverage Status Go Report Card

Simple client with utility methods for

  • opening and closing DB - Open, Close
  • creation of initial entities (for example buckets) - InitEntity
  • read transaction with callback - ReadTransaction
  • write transaction with callback - WriteTransaction
  • delete entry from bucket - DeleteWithTransaction
  • find nested bucked according to path - FindBucket

Documentation

Index

Constants

View Source
const (
	// DefaultBindAddress is the default binding interface if none is specified.
	DefaultDir      = ""
	DefaultFilename = "boltdb.db"
)

Variables

This section is empty.

Functions

func DeferRollback

func DeferRollback(tx *bolt.Tx, success *bool)

func FindBucket

func FindBucket(b *bolt.Bucket, path []string) (*bolt.Bucket, string)

Find nested bucked according to path. In case there is no some bucket in path, then return last not found name of bucket.

func I2B

func I2B(v uint64) []byte

Types

type Client

type Client struct {
	Db *bolt.DB
	// contains filtered or unexported fields
}

Client represents a boltdbclient to the underlying BoltDB data store.

func NewClient

func NewClient(config Config) *Client

Creates new client

func (*Client) Close

func (c *Client) Close() error

Close closes then underlying BoltDB database.

func (*Client) DeleteWithTransaction

func (client *Client) DeleteWithTransaction(bucket []byte, id string) error

Delete entry from bucket

func (*Client) InitEntity

func (client *Client) InitEntity(initEntityCallback TransactionCallback) error

Creation of initial entities (for example buckets)

func (*Client) Open

func (c *Client) Open() (string, error)

Open opens and initializes the BoltDB database.

func (*Client) Path

func (c *Client) Path() string

func (*Client) ReadTransaction

func (client *Client) ReadTransaction(read TransactionCallback) error

Read transaction with callback

func (*Client) WriteTransaction

func (client *Client) WriteTransaction(write TransactionCallback) error

Write transaction with callback

type Config

type Config struct {
	Dir      string `toml:"dir"`
	Filename string `toml:"filename"`
}

func NewConfig

func NewConfig() Config

NewConfig returns a new instance of Config with defaults.

func (Config) Validate

func (config Config) Validate() error

func (*Config) WithDefaults

func (c *Config) WithDefaults() *Config

WithDefaults takes the given config and returns a new config with any required default values set.

type TransactionCallback

type TransactionCallback func(*bolt.Tx) error

Jump to

Keyboard shortcuts

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