Documentation

Overview

Package k2hash implements a k2hash library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

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

Attr holds attribute names and values.

func (*Attr) String

func (r *Attr) String() string

String returns a text representation of the object.

type GetResult

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

GetResult holds the result of Get.

func (*GetResult) Bytes

func (r *GetResult) Bytes() []byte

Bytes returns the value in binary format.

func (*GetResult) String

func (r *GetResult) String() string

String returns the value in text format.

type K2hash

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

K2hash keeps configurations, and it is responsible for creating request handles with a k2hash database files and closing them.

func NewK2hash

func NewK2hash(f string, options ...func(*K2hash)) (*K2hash, error)

NewK2hash returns a new k2hash instance.

func (*K2hash) AddAttr

func (k2h *K2hash) AddAttr(k interface{}, ak interface{}, av interface{}, options ...func(*Params)) (bool, error)

AddAttr adds an attribute with a value to a key.

func (*K2hash) AddAttrPluginLibrary

func (k2h *K2hash) AddAttrPluginLibrary(file string) (bool, error)

AddAttrPluginLibrary loads a shared library for processing attribute data.

func (*K2hash) AddDecryptionPassword

func (k2h *K2hash) AddDecryptionPassword(pass string) (bool, error)

AddDecryptionPassword sets the decryption passphrase.

func (*K2hash) AddSubKey

func (k2h *K2hash) AddSubKey(k interface{}, s interface{}, v interface{}, options ...func(*Params)) (bool, error)

AddSubKey add a subkey to a key.

func (*K2hash) BeginTx

func (k2h *K2hash) BeginTx(file string, options ...func(*TxParams)) (bool, error)

BeginTx enables transaction.

func (*K2hash) BumpDebugLevel

func (k2h *K2hash) BumpDebugLevel()

BumpDebugLevel changes the log level.

func (*K2hash) Close

func (k2h *K2hash) Close() (bool, error)

Close closes a k2hash file.

func (*K2hash) Create

func (k2h *K2hash) Create() bool

Create creates a k2hash file. It returns a error if the file already exists.

func (*K2hash) DumpElementTable

func (k2h *K2hash) DumpElementTable() bool

DumpElementTable dumps K2HASH's Element table information to a file referred by FILE pointer.

func (*K2hash) DumpFull

func (k2h *K2hash) DumpFull() bool

DumpFull dumps K2HASH's all information.

func (*K2hash) DumpFullKeyTable

func (k2h *K2hash) DumpFullKeyTable() bool

DumpFullKeyTable dumps K2HASH's hash key and subkey information to a file referred by FILE pointer.

func (*K2hash) DumpHead

func (k2h *K2hash) DumpHead() bool

DumpHead dumps K2HASH header information to a file referred by FILE pointer.

func (*K2hash) DumpKeyTable

func (k2h *K2hash) DumpKeyTable() bool

DumpKeyTable dumps K2HASH's hash key table information to a file referred by FILE pointer.

func (*K2hash) DumpToFile

func (k2h *K2hash) DumpToFile(file string, ignoreError bool) (bool, error)

DumpToFile saves data from a file as a serialized data.

func (*K2hash) EnableEncryption

func (k2h *K2hash) EnableEncryption(enable bool, file string) (bool, error)

EnableEncryption enables the k2hash file attributes of data encryption.

func (*K2hash) EnableHistory

func (k2h *K2hash) EnableHistory(enable bool) (bool, error)

EnableHistory enables the k2hash file attributes of history.

func (*K2hash) EnableMtime

func (k2h *K2hash) EnableMtime(enable bool) (bool, error)

EnableMtime enables the k2hash file attributes of modification time.

func (*K2hash) Get

func (k2h *K2hash) Get(k interface{}, options ...func(*Params)) (*GetResult, error)

Get returns data from a k2hash file.

func (*K2hash) GetAttrs

func (k2h *K2hash) GetAttrs(k string) ([]Attr, error)

GetAttrs returns a slice of string.

func (*K2hash) GetHandle

func (k2h *K2hash) GetHandle() C.k2h_h

GetHandle returns a k2hash file handle.

func (*K2hash) GetSubKeys

func (k2h *K2hash) GetSubKeys(k string) ([]string, error)

GetSubKeys returns subkeys to a key.

func (*K2hash) GetTxFileFD

func (k2h *K2hash) GetTxFileFD() int32

GetTxFileFD returns the file descriptor for transaction file.

func (*K2hash) GetTxThreadPoolSize

func (k2h *K2hash) GetTxThreadPoolSize() (int32, error)

GetTxThreadPoolSize returns the number of thread pools.

func (*K2hash) LoadDebugEnv

func (k2h *K2hash) LoadDebugEnv() bool

LoadDebugEnv defines the log level and the file by using K2HDBGMODE, K2HDBGFILE.

func (*K2hash) LoadFromFile

func (k2h *K2hash) LoadFromFile(file string, ignoreError bool) (bool, error)

LoadFromFile loads data from archive files.

func (*K2hash) LoadHashLibrary

func (k2h *K2hash) LoadHashLibrary(filepath string) bool

LoadHashLibrary loads the hash library.

func (*K2hash) LoadTxLibrary

func (k2h *K2hash) LoadTxLibrary(filepath string) bool

LoadTxLibrary loads the hash library.

func (*K2hash) Open

func (k2h *K2hash) Open() (bool, error)

Open opens a k2hash file.

func (*K2hash) PrintAttrInformation

func (k2h *K2hash) PrintAttrInformation()

PrintAttrInformation prints attributes to stderr.

func (*K2hash) PrintAttrVersion

func (k2h *K2hash) PrintAttrVersion()

PrintAttrVersion prints attribute plugins to stderr.

func (*K2hash) PrintState

func (k2h *K2hash) PrintState() bool

PrintState prints k2hash file stats.

func (*K2hash) PrintVersion

func (k2h *K2hash) PrintVersion()

PrintVersion prints the k2hash library version and the credit.

func (*K2hash) Remove

func (k2h *K2hash) Remove(k interface{}, options ...func(*RemoveParams)) (bool, error)

Remove removes a key or a subkey.

func (*K2hash) Rename

func (k2h *K2hash) Rename(o interface{}, n interface{}) (bool, error)

Rename renames an old key with a new key.

func (*K2hash) Set

func (k2h *K2hash) Set(k interface{}, v interface{}, options ...func(*Params)) (bool, error)

Set returns true if successfully set a key with a value.

func (*K2hash) SetDebugFile

func (k2h *K2hash) SetDebugFile(filepath string) bool

SetDebugFile defines the file where log messages are saved.

func (*K2hash) SetDebugLevelError

func (k2h *K2hash) SetDebugLevelError()

SetDebugLevelError logs error level messages.

func (*K2hash) SetDebugLevelMessage

func (k2h *K2hash) SetDebugLevelMessage()

SetDebugLevelMessage logs info or higher level messages.

func (*K2hash) SetDebugLevelSilent

func (k2h *K2hash) SetDebugLevelSilent()

SetDebugLevelSilent disables logging.

func (*K2hash) SetDebugLevelWarning

func (k2h *K2hash) SetDebugLevelWarning()

SetDebugLevelWarning logs warning or higher level messages.

func (*K2hash) SetDefaultEncryptionPassword

func (k2h *K2hash) SetDefaultEncryptionPassword(pass string) (bool, error)

SetDefaultEncryptionPassword sets the encryption passphrase.

func (*K2hash) SetExpirationDuration

func (k2h *K2hash) SetExpirationDuration(duration int) (bool, error)

SetExpirationDuration enables the k2hash file attributes of modification time.

func (*K2hash) SetSignalUser1

func (k2h *K2hash) SetSignalUser1() bool

SetSignalUser1 changes log level by receiving SIGUSR1 signal.

func (*K2hash) SetSubKeys

func (k2h *K2hash) SetSubKeys(k interface{}, sk interface{}) (bool, error)

SetSubKeys links another key as a child to the key.

func (*K2hash) SetTxThreadPoolSize

func (k2h *K2hash) SetTxThreadPoolSize(pool int32) (bool, error)

SetTxThreadPoolSize set the number of thread pools.

func (*K2hash) StopTx

func (k2h *K2hash) StopTx() (bool, error)

StopTx disables transaction.

func (*K2hash) String

func (k2h *K2hash) String() string

String returns a text representation of the object.

func (*K2hash) UnloadHashLibrary

func (k2h *K2hash) UnloadHashLibrary() bool

UnloadHashLibrary unloads the loaded hash library.

func (*K2hash) UnloadTxLibrary

func (k2h *K2hash) UnloadTxLibrary() bool

UnloadTxLibrary unloads the loaded hash library.

func (*K2hash) UnsetDebugFile

func (k2h *K2hash) UnsetDebugFile() bool

UnsetDebugFile disables saving log messages to a file.

func (*K2hash) UnsetTxThreadPoolSize

func (k2h *K2hash) UnsetTxThreadPoolSize() (bool, error)

UnsetTxThreadPoolSize set the number of thread pools zero.

type KeyQueue

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

KeyQueue keeps a queue configurations.

func NewKeyQueue

func NewKeyQueue(h *K2hash, options ...func(*KeyQueue)) (*KeyQueue, error)

NewKeyQueue returns a new k2hash queue instance.

func (*KeyQueue) Count

func (q *KeyQueue) Count() (int, error)

Count returns the number of k2hash queue elements.

func (*KeyQueue) Free

func (q *KeyQueue) Free() (bool, error)

Free destroys a k2hash queue handle.

func (*KeyQueue) Pop

func (q *KeyQueue) Pop(options ...func(*Params)) (string, error)

Pop retrieves a value from the queue.

func (*KeyQueue) Push

func (q *KeyQueue) Push(v interface{}, options ...func(*Params)) (bool, error)

Push adds a value to the queue.

func (*KeyQueue) String

func (q *KeyQueue) String() string

String returns a text representation of the object.

type Params

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

Params stores parameters for k2hash C API.

func (*Params) String

func (p *Params) String() string

String returns a text representation of the object.

type Queue

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

Queue keeps a queue configurations.

func NewQueue

func NewQueue(h *K2hash, options ...func(*Queue)) (*Queue, error)

NewQueue returns a new k2hash queue instance.

func (*Queue) Count

func (q *Queue) Count() (int, error)

Count returns the number of k2hash queue elements.

func (*Queue) Free

func (q *Queue) Free() (bool, error)

Free destroys a k2hash queue handle.

func (*Queue) Pop

func (q *Queue) Pop(options ...func(*Params)) (string, error)

Pop retrieves a value from the queue.

func (*Queue) Push

func (q *Queue) Push(v interface{}, options ...func(*Params)) (bool, error)

Push adds a value to the queue.

func (*Queue) String

func (q *Queue) String() string

String returns a text representation of the object.

type QueueParams

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

QueueParams stores parameters for k2hash queue C API.

type RemoveParams

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

RemoveParams is a parameter set of remove.

type TxParams

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

TxParams is a parameter set of transaction.