cfghive

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

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

Go to latest
Published: Oct 9, 2023 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HiveTypeBool = iota
	HiveTypeByte
	HiveTypeInt64
	HiveTypeUint64
	HiveTypeFloat64
	HiveTypeInt
	HiveTypeUint
	HiveTypeFloat32
	HiveTypeString
	HiveTypeBytes
	HiveTypeSub
)

Variables

View Source
var HiveTypeMap map[int]string = map[int]string{
	0:  "bool",
	1:  "byte",
	2:  "int64",
	3:  "uint64",
	4:  "float64",
	5:  "int",
	6:  "uint",
	7:  "float32",
	8:  "string",
	9:  "bytes",
	10: "sub",
}

Functions

func GenericMapToSubMap

func GenericMapToSubMap(v map[string]interface{}) (map[string]HiveValue, error)

func HiveDump

func HiveDump(data *map[string]HiveValue)

func HiveMapToGeneric

func HiveMapToGeneric(hive map[string]HiveValue) map[string]interface{}

func HiveSize

func HiveSize(data map[string]HiveValue) uint

Types

type BinHive

type BinHive struct {
	Stream *bufio.ReadWriter
	// contains filtered or unexported fields
}

BinHive is a hive built on top of MemHive that can be serialized and loaded to/from a writer.

func NewBinHive

func NewBinHive(compression bool, level uint8) *BinHive

func (*BinHive) Characteristics

func (h *BinHive) Characteristics() HiveCharacteristics

func (*BinHive) Commit

func (h *BinHive) Commit() error

func (*BinHive) Delete

func (h *BinHive) Delete(key string)

func (*BinHive) Get

func (h *BinHive) Get(key string) (interface{}, error)

func (*BinHive) GetBool

func (h *BinHive) GetBool(key string) (bool, error)

func (*BinHive) GetData

func (h *BinHive) GetData() *map[string]HiveValue

func (*BinHive) GetFloat

func (h *BinHive) GetFloat(key string) (float64, error)

func (*BinHive) GetInt

func (h *BinHive) GetInt(key string) (int, error)

func (*BinHive) GetString

func (h *BinHive) GetString(key string) (*string, error)

func (*BinHive) Load

func (h *BinHive) Load() error

func (*BinHive) NewSub

func (h *BinHive) NewSub(key string)

func (*BinHive) Save

func (h *BinHive) Save() error

func (*BinHive) Set

func (h *BinHive) Set(key string, value interface{}) error

func (*BinHive) SetBool

func (h *BinHive) SetBool(key string, value bool) error

func (*BinHive) SetFloat

func (h *BinHive) SetFloat(key string, value float64) error

func (*BinHive) SetInt

func (h *BinHive) SetInt(key string, value int) error

func (*BinHive) SetString

func (h *BinHive) SetString(key string, value string) error

type Hive

type Hive interface {
	// Characteristics Gets the characteristics of the hive.
	Characteristics() HiveCharacteristics

	// Load the hive from some persistent storage.
	Load() error

	// Get Gets a value from the hive.
	// Returns nil, false if the value does not exist.
	Get(key string) (*HiveValue, error)
	GetBool(key string) (bool, error)
	GetInt(key string) (int, error)
	GetFloat(key string) (float64, error)
	GetString(key string) (*string, error)

	// Set Sets a value in the hive.
	// If the value already exists, it's replaced.
	Set(key string, value interface{}) error
	SetBool(key string, value bool) error
	SetInt(key string, value int) error
	SetFloat(key string, value float64) error
	SetString(key string, value string) error

	// Delete Deletes a value from the hive.
	// Returns the old value, or nil if the value did not exist.
	Delete(key string)

	// NewSub Create a sub-hive with the given key.
	NewSub(key string)

	// Rollback Rolls back the hive to the last commit.
	// Returns true if the hive was rolled back.
	// For some hives, this is a no-op.
	Rollback() (bool, error)

	// Commit Commits the hive.
	// Returns true if the hive was committed.
	// For some hives, this is a no-op.
	Commit() (bool, error)

	// Save Saves the hive to some persistent storage.
	// Unlike Commit this always saves the hive.
	Save() error

	// GetData Get the data of the hive.
	GetData() *map[string]HiveValue
}

type HiveCharacteristics

type HiveCharacteristics struct {
	// Is the hive implementation transactional?
	IsTxn bool
	// Is the hive implementation persistent?
	IsPersistent bool
	// Is the hive implementation thread-safe?
	IsThreadSafe bool
}

type HiveValue

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

func NewHiveValue

func NewHiveValue(v interface{}) (HiveValue, error)

func (*HiveValue) Bool

func (v *HiveValue) Bool() (bool, error)

func (*HiveValue) Byte

func (v *HiveValue) Byte() (byte, error)

func (*HiveValue) Bytes

func (v *HiveValue) Bytes() ([]byte, error)

func (*HiveValue) Float32

func (v *HiveValue) Float32() (float32, error)

func (*HiveValue) Float64

func (v *HiveValue) Float64() (float64, error)

func (*HiveValue) Int

func (v *HiveValue) Int() (int, error)

func (*HiveValue) Int64

func (v *HiveValue) Int64() (int64, error)

func (*HiveValue) IsStoredType

func (v *HiveValue) IsStoredType(t byte) bool

func (*HiveValue) Len

func (v *HiveValue) Len() uint64

func (*HiveValue) String

func (v *HiveValue) String() (string, error)

func (*HiveValue) Sub

func (v *HiveValue) Sub() (map[string]HiveValue, error)

func (*HiveValue) Type

func (v *HiveValue) Type() byte

func (*HiveValue) TypeString

func (v *HiveValue) TypeString() string

func (*HiveValue) Uint

func (v *HiveValue) Uint() (uint, error)

func (*HiveValue) Uint64

func (v *HiveValue) Uint64() (uint64, error)

func (*HiveValue) Value

func (v *HiveValue) Value() interface{}

type MemHive

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

MemHive A hive that is memory resident.

func NewMemHive

func NewMemHive() (*MemHive, error)

NewMemHive Creates a new file hive.

func (*MemHive) Characteristics

func (h *MemHive) Characteristics() HiveCharacteristics

Characteristics Gets the characteristics of the hive.

func (*MemHive) Commit

func (h *MemHive) Commit() (bool, error)

func (*MemHive) Delete

func (h *MemHive) Delete(key string)

func (*MemHive) Get

func (h *MemHive) Get(key string) (*HiveValue, error)

func (*MemHive) GetBool

func (h *MemHive) GetBool(key string) (bool, error)

func (*MemHive) GetData

func (h *MemHive) GetData() *map[string]HiveValue

func (*MemHive) GetFloat

func (h *MemHive) GetFloat(key string) (float64, error)

func (*MemHive) GetInt

func (h *MemHive) GetInt(key string) (int, error)

func (*MemHive) GetString

func (h *MemHive) GetString(key string) (*string, error)

func (*MemHive) Load

func (h *MemHive) Load() error

Load Loads the hive from the file. the file is a JSON file.

func (*MemHive) NewSub

func (h *MemHive) NewSub(key string)

func (*MemHive) Rollback

func (h *MemHive) Rollback() (bool, error)

func (*MemHive) Save

func (h *MemHive) Save() error

func (*MemHive) Set

func (h *MemHive) Set(key string, value interface{}) error

func (*MemHive) SetBool

func (h *MemHive) SetBool(key string, value bool) error

func (*MemHive) SetFloat

func (h *MemHive) SetFloat(key string, value float64) error

func (*MemHive) SetInt

func (h *MemHive) SetInt(key string, value int) error

func (*MemHive) SetString

func (h *MemHive) SetString(key string, value string) error

Directories

Path Synopsis
cmd module

Jump to

Keyboard shortcuts

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