backend

package
v0.0.0-...-982e07a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package backend provides a common filesystem Backend interface for filesystem.KeyStore as well as some basic implementations of it.

Backend treats "paths" like UNIX filesystems usually do. That is, components are separated by forward slash "/" character and paths are expected to contain valid UTF-8 text. However, paths are not interpreted in any way and may actually contain arbitrary byte sequences, except for "/" and "\0" bytes that are treated specially.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDirectory       = errors.New("root key directory is not a directory")
	ErrInvalidPermissions = errors.New("invalid key directory access permissions")
	ErrInvalidVersion     = errors.New("invalid keystore version file content")
)

Errors returned by DirectoryBackend:

View Source
var ErrLockTimeout = errors.New("timed out while waiting for lock")

ErrLockTimeout errors returned by RedisBackend:

Functions

func CheckDirectoryVersion

func CheckDirectoryVersion(rootDir string) error

CheckDirectoryVersion checks whether a key directory is of expected version.

Types

type Backend

type Backend api.Backend

Backend defines how KeyStore persists internal key data.

type DirectoryBackend

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

DirectoryBackend keeps data in filesystem directory hierarchy.

func CreateDirectoryBackend

func CreateDirectoryBackend(root string) (*DirectoryBackend, error)

CreateDirectoryBackend opens a directory backend at given root path. The root directory will be created if it does not exist.

func OpenDirectoryBackend

func OpenDirectoryBackend(root string) (*DirectoryBackend, error)

OpenDirectoryBackend opens an existing directory backend at given root path.

func (*DirectoryBackend) Close

func (b *DirectoryBackend) Close() error

Close this backend instance, freeing any associated resources.

func (*DirectoryBackend) Get

func (b *DirectoryBackend) Get(path string) ([]byte, error)

Get data at given path.

func (*DirectoryBackend) ListAll

func (b *DirectoryBackend) ListAll() ([]string, error)

ListAll enumerates all paths currently stored. The paths are returned in lexicographical order.

func (*DirectoryBackend) Lock

func (b *DirectoryBackend) Lock() error

Lock acquires an exclusive lock on the store.

func (*DirectoryBackend) Put

func (b *DirectoryBackend) Put(path string, data []byte) error

Put data at given path.

func (*DirectoryBackend) RLock

func (b *DirectoryBackend) RLock() error

RLock acquires a shared lock on the store.

func (*DirectoryBackend) RUnlock

func (b *DirectoryBackend) RUnlock() error

RUnlock releases currently held shared lock.

func (*DirectoryBackend) Rename

func (b *DirectoryBackend) Rename(oldpath, newpath string) error

Rename oldpath into newpath.

func (*DirectoryBackend) RenameNX

func (b *DirectoryBackend) RenameNX(oldpath, newpath string) error

RenameNX renames oldpath into newpath non-destructively.

func (*DirectoryBackend) Unlock

func (b *DirectoryBackend) Unlock() error

Unlock releases currently held exclusive lock.

type InMemory

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

InMemory backend is a dummy backend which keeps all data in memory. It is mostly useful for testing.

func NewInMemory

func NewInMemory() *InMemory

NewInMemory makes a new empty in-memory backend.

func (*InMemory) Close

func (m *InMemory) Close() error

Close this backend instance, freeing any associated resources.

func (*InMemory) Get

func (m *InMemory) Get(path string) ([]byte, error)

Get data at given path.

func (*InMemory) ListAll

func (m *InMemory) ListAll() ([]string, error)

ListAll enumerates all paths currently stored. The paths are returned in lexicographical order.

func (*InMemory) Lock

func (m *InMemory) Lock() error

Lock acquires an exclusive lock on the store.

func (*InMemory) Put

func (m *InMemory) Put(path string, data []byte) error

Put data at given path.

func (*InMemory) RLock

func (m *InMemory) RLock() error

RLock acquires a shared lock on the store.

func (*InMemory) RUnlock

func (m *InMemory) RUnlock() error

RUnlock releases currently held shared lock.

func (*InMemory) Rename

func (m *InMemory) Rename(oldpath, newpath string) error

Rename oldpath into newpath atomically.

func (*InMemory) RenameNX

func (m *InMemory) RenameNX(oldpath, newpath string) error

RenameNX renames oldpath into newpath non-destructively.

func (*InMemory) Unlock

func (m *InMemory) Unlock() error

Unlock releases currently held exclusive lock.

type RedisBackend

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

RedisBackend keeps key data in Redis database.

func CreateRedisBackend

func CreateRedisBackend(config *RedisConfig) (*RedisBackend, error)

CreateRedisBackend opens a Redis backend at given root path. The root directory will be created if it does not exist.

func OpenRedisBackend

func OpenRedisBackend(config *RedisConfig) (*RedisBackend, error)

OpenRedisBackend opens a Redis backend at given root path.

func (*RedisBackend) Close

func (b *RedisBackend) Close() error

Close this backend instance, freeing any associated resources.

func (*RedisBackend) Get

func (b *RedisBackend) Get(path string) ([]byte, error)

Get data at given path.

func (*RedisBackend) ListAll

func (b *RedisBackend) ListAll() ([]string, error)

ListAll enumerates all paths currently stored. The paths are returned in lexicographical order.

func (*RedisBackend) Lock

func (b *RedisBackend) Lock() error

Lock acquires an exclusive lock on the store.

func (*RedisBackend) Put

func (b *RedisBackend) Put(path string, data []byte) error

Put data at given path.

func (*RedisBackend) RLock

func (b *RedisBackend) RLock() error

RLock acquires a shared lock on the store.

func (*RedisBackend) RUnlock

func (b *RedisBackend) RUnlock() error

RUnlock releases currently held shared lock.

func (*RedisBackend) Rename

func (b *RedisBackend) Rename(oldpath, newpath string) error

Rename oldpath into newpath.

func (*RedisBackend) RenameNX

func (b *RedisBackend) RenameNX(oldpath, newpath string) error

RenameNX renames oldpath into newpath non-destructively.

func (*RedisBackend) Unlock

func (b *RedisBackend) Unlock() error

Unlock releases currently held exclusive lock.

type RedisConfig

type RedisConfig struct {
	Options *redis.Options
	RootDir string
}

RedisConfig defines Redis keystore configuration.

Directories

Path Synopsis
api
Package api defines abstract backend interface.
Package api defines abstract backend interface.
tests
Package tests provides conformity test suite for KeyStore Backend API.
Package tests provides conformity test suite for KeyStore Backend API.

Jump to

Keyboard shortcuts

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