Documentation ¶
Overview ¶
Package persistence adds a layer which handles data storage. This package separates the data from the business layer and is responsible for saving and retrieving it.
Index ¶
Constants ¶
const KeyLength = encryption.KeyLength
KeyLength represents the byte size of the key.
Variables ¶
This section is empty.
Functions ¶
func CheckStoragePermission ¶ added in v1.5.0
CheckStoragePermission returns an error if we don't have both read and write access to a directory.
func EnsureDirectoryExists ¶ added in v1.5.0
EnsureDirectoryExists creates a new directory in a base path if it doesn't exist, returns nil if it does, and errors out if the base path doesn't exist.
Types ¶
type DataDescriptor ¶
DataDescriptor is an interface representing data saved in the persistence layer represented by Handle.
type Handle ¶
type Handle interface { // Save takes the provided data and persists it under the given name in the // provided directory appropriate for the given persistent storage // implementation. Save(data []byte, directory string, name string) error // Snapshot takes the provided data and persists it as an unique snapshot // file in the provided directory appropriate for the given persistent // storage implementation. Snapshot(data []byte, directory string, name string) error // ReadAll returns all non-archived data. It returns two channels: the first // channel returned is a non-buffered channel streaming DataDescriptors of // all data read. The second channel is a non-buffered channel streaming all // errors occurred during reading. Returned channels can be integrated // in a pipeline pattern. The function is non-blocking. Channels are closed // when there is no more to be read. ReadAll() (<-chan DataDescriptor, <-chan error) // Archive marks the entire directory with the name provided as archived // so that the data in that directory is not returned from ReadAll. Archive(directory string) error }
Handle is an interface for data persistence. Underlying implementation can write data e.g. to disk, cache, or hardware module.
func NewDiskHandle ¶
NewDiskHandle creates on-disk data persistence handle
func NewEncryptedPersistence ¶
NewEncryptedPersistence creates an adapter for the disk persistence to store data in an encrypted format