Documentation
¶
Index ¶
- func Exists(err error) bool
- type Extender
- type Filestore
- func (f *Filestore) Close()
- func (f *Filestore) Delete(key string) error
- func (f *Filestore) Get(key string, loadIntoThisObject Unmarshaler) error
- func (f *Filestore) GetBytes(key string) ([]byte, error)
- func (f *Filestore) GetInterface(key string, v interface{}) error
- func (f *Filestore) Set(key string, objectToStore Marshaler) error
- func (f *Filestore) SetBytes(key string, data []byte) error
- func (f *Filestore) SetInterface(key string, objectToStore interface{}) error
- func (f *Filestore) SetNonceGenerator(csprng io.Reader)
- func (f *Filestore) Transaction(op TransactionOperation, keys ...string) error
- type KeyValue
- type Marshaler
- type Memstore
- func (m *Memstore) Delete(key string) error
- func (m *Memstore) Get(key string, loadIntoThisObject Unmarshaler) error
- func (m *Memstore) GetBytes(key string) ([]byte, error)
- func (m *Memstore) GetInterface(key string, objectToLoad interface{}) error
- func (m *Memstore) Set(key string, objectToStore Marshaler) error
- func (m *Memstore) SetBytes(key string, data []byte) error
- func (m *Memstore) SetInterface(key string, objectToStore interface{}) error
- func (m *Memstore) Transaction(op TransactionOperation, keys ...string) error
- type Operable
- type OperableOps
- type TransactionOperation
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Extender ¶ added in v0.4.0
type Extender interface { // Extend can be used to add more keys to the current transaction // if an error is returned, abort and return it Extend(keys []string) (map[string]Operable, error) // IsClosed returns true if the current transaction is in scope // will always be true if inside the execution of the transaction IsClosed() bool }
type Filestore ¶
Filestore implements an ekv by reading and writing to files in a directory.
func NewFilestore ¶
NewFilestore returns an initialized filestore object or an error if it can't read and write to the directory/.ekv.1/2 file. Note that this file is not used other than to verify read/write capabilities on the directory.
func NewFilestoreWithNonceGenerator ¶
NewFilestoreWithNonceGenerator returns an initialized filestore object that uses a custom RNG for Nonce generation.
func (*Filestore) Close ¶
func (f *Filestore) Close()
Close is equivalent to nil'ing out the Filestore object. This function is in place for the future when we add secure memory storage for keys.
func (*Filestore) Get ¶
func (f *Filestore) Get(key string, loadIntoThisObject Unmarshaler) error
Get the value for the given key per [KeyValue.Get]
func (*Filestore) GetInterface ¶
GetInterface uses json to encode and get data per [KeyValue.GetInterface]
func (*Filestore) SetInterface ¶
SetInterface uses json to encode and set data per [KeyValue.SetInterface]
func (*Filestore) SetNonceGenerator ¶
SetNonceGenerator sets the cryptographically secure pseudo-random number generator (csprng) used during encryption to generate nonces.
func (*Filestore) Transaction ¶ added in v0.3.0
func (f *Filestore) Transaction(op TransactionOperation, keys ...string) error
Transaction implements [KeyValue.Transaction]
type KeyValue ¶
type KeyValue interface { // Set stores using an object that can marshal itself. Set(key string, objectToStore Marshaler) error // Get loads into an object that can unmarshal itself. Get(key string, loadIntoThisObject Unmarshaler) error // Delete destroys a key. Delete(key string) error // SetInterface uses a JSON encoder to store an interface object. SetInterface(key string, objectToSTore interface{}) error // GetInterface uses a JSON decode to load an interface object. GetInterface(key string, v interface{}) error // SetBytes stores raw bytes. SetBytes(key string, data []byte) error // GetBytes loads raw bytes. GetBytes(key string) ([]byte, error) // Transaction locks a set of keys while they are being mutated and // allows the function to operate on them exclusively. // More keys can be added to the transaction, but they must only be operated // on in conjunction with the previously locked keys otherwise deadlocks can // occur // If the op returns an error, the operation will be aborted. Transaction(op TransactionOperation, keys ...string) error }
KeyValue is the interface that ekv implements. Simple functions are provided for objects that can Marshal and Unmarshal themselves, and an interface version of these is provided which should use JSON or another generic object encoding system.
type Marshaler ¶
type Marshaler interface {
Marshal() []byte
}
Marshaler interface defines objects which can "Marshal" themselves into a byte slice. This should produce a byte slice that can be used to fully reconstruct the object later.
type Memstore ¶
type Memstore struct {
// contains filtered or unexported fields
}
Memstore is an unencrypted memory-based map that implements the KeyValue interface.
func MakeMemstore ¶ added in v0.1.7
func MakeMemstore() *Memstore
MakeMemstore returns a new Memstore with a newly initialised a new map.
func (*Memstore) Get ¶
func (m *Memstore) Get(key string, loadIntoThisObject Unmarshaler) error
Get implements [KeyValue.Get]
func (*Memstore) GetInterface ¶
GetInterface gets the value using a JSON encoder per [KeyValue.GetInterface]
func (*Memstore) SetInterface ¶
SetInterface sets the value using a JSON encoder per [KeyValue.SetInterface]
func (*Memstore) Transaction ¶ added in v0.3.0
func (m *Memstore) Transaction(op TransactionOperation, keys ...string) error
Transaction implements [KeyValue.Transaction]
type Operable ¶ added in v0.4.0
type Operable interface { // Key returns the key this interface is operating on Key() string // Exists returns if the file currently exists // will panic if the current transaction isn't in scope Exists() bool // Delete deletes the file at the key and destroy it. // will panic if the current transaction isn't in scope Delete() // Set stores raw bytes. // will panic if the current transaction isn't in scope Set(data []byte) // Get loads raw bytes. // will panic if the current transaction isn't in scope Get() ([]byte, bool) // Flush executes the operation and returns an error if the operation // failed. It will set the operable to closed as well. // if flush is not called, it will be called by the handler Flush() error // IsClosed returns true if the current transaction is in scope // will always be true if inside the execution of the transaction IsClosed() bool }
Operable describes edits to a single key inside a transaction
type OperableOps ¶ added in v0.4.0
type OperableOps uint8
type TransactionOperation ¶ added in v0.3.0
type Unmarshaler ¶
Unmarshaler interface defines objects which can be initialized by a byte slice. An error should be returned if the object cannot be decoded or, optionally, when Unmarshal is called against a pre-initialized object.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package portableOS contains global OS functions that can be overwritten to be used with other filesystems not supported by the os package, such as wasm.
|
Package portableOS contains global OS functions that can be overwritten to be used with other filesystems not supported by the os package, such as wasm. |