storage

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 6 Imported by: 0

README

storage

go get code.uint32.ru/tiny/storage

This is a work in progress package.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKey is returned when key validation
	// for particular implementation of Storage fails.
	ErrInvalidKey = errinternal.ErrInvalidKey
	// ErrNotFound is returned when object is not found
	// in Storage.
	ErrNotFound = errinternal.ErrNotFound
)

Functions

This section is empty.

Types

type Storage

type Storage interface {
	// Save puts object with name 'key' into the store.
	// If a key already exists it gets overwritten.
	Save(key string, data []byte) error
	// Load returns contents of object named 'key' or
	// ErrNotFound.
	Load(key string) ([]byte, error)
	// Delete removes object named 'key' from the store.
	// If key does not exist Delete returns nil.
	Delete(key string) error
}

Storage is a very basic object store.

func NewFS

func NewFS(path string) (Storage, error)

NewFS established a key/value within the directory 'path' and uses it as underlying physical store. Note that the implementation requires keys to be at least 3 characters long. Key "abcd" will be stored in /path/a/b/abcd.

func NewNats

func NewNats(store nats.ObjectStore) Storage

NewNats wraps the provided ObjectStore with Storage interface.

func NewVault

func NewVault(client *api.Client, path string) Storage

NewVault uses provided Vault client to store objects. All objects are stored as a single secret, a JSON object where key are keys and values are base64 encoded bytes of saved object. If secret specified by path does not exist it will be created on first call to Storage methods. Note that a secret in vault gets updated (a new version of secret is created) on every save/delete operation.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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