locodebolt

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a descriptor of the FrostFS BoltDB location database.

For correct operation, DB must be created using the constructor (New) based on the required parameters and optional components.

After successful creation, DB must be opened through Open call. After successful opening, DB is ready to work through API (until Close call).

Upon completion of work with the DB, it must be closed by Close method.

func New

func New(prm Prm, opts ...Option) *DB

New creates a new instance of the DB.

Panics if at least one value of the parameters is invalid.

The created DB requires calling the Open method in order to initialize required resources.

func (*DB) Close

func (db *DB) Close() error

Close closes an underlying BoltDB instance.

Must not be called before successful Open call.

func (*DB) Get

func (db *DB) Get(key locodedb.Key) (rec *locodedb.Record, err error)

Get reads the record by key from underlying BoltDB instance.

Returns an error if no record is presented by key in DB.

Must not be called before successful Open call.

func (*DB) Open

func (db *DB) Open() error

Open opens an underlying BoltDB instance.

Timeout of BoltDB opening is 3s (only for Linux or Darwin).

Opens BoltDB in read-only mode if DB is read-only.

func (*DB) Put

func (db *DB) Put(key locodedb.Key, rec locodedb.Record) error

Put saves the record by key in an underlying BoltDB instance.

Country code from the key is used for allocating the 1st level buckets. Records are stored in country buckets by the location code from the key. The records are stored in internal binary JSON format.

Must not be called before successful Open call. Must not be called in read-only mode: behavior is undefined.

type Option

type Option func(*options)

Option sets an optional parameter of DB.

func ReadOnly

func ReadOnly() Option

ReadOnly enables read-only mode of the DB.

Do not call DB.Put method on instances with this option: the behavior is undefined.

type Prm

type Prm struct {
	// Path to BoltDB file with FrostFS location database.
	//
	// Must not be empty.
	Path string
}

Prm groups the required parameters of the DB's constructor.

All values must comply with the requirements imposed on them. Passing incorrect parameter values will result in constructor failure (error or panic depending on the implementation).

Jump to

Keyboard shortcuts

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