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 ¶
- Variables
- func CheckDirectoryVersion(rootDir string) error
- type Backend
- type DirectoryBackend
- func (b *DirectoryBackend) Close() error
- func (b *DirectoryBackend) Get(path string) ([]byte, error)
- func (b *DirectoryBackend) ListAll() ([]string, error)
- func (b *DirectoryBackend) Lock() error
- func (b *DirectoryBackend) Put(path string, data []byte) error
- func (b *DirectoryBackend) RLock() error
- func (b *DirectoryBackend) RUnlock() error
- func (b *DirectoryBackend) Rename(oldpath, newpath string) error
- func (b *DirectoryBackend) RenameNX(oldpath, newpath string) error
- func (b *DirectoryBackend) Unlock() error
- type InMemory
- func (m *InMemory) Close() error
- func (m *InMemory) Get(path string) ([]byte, error)
- func (m *InMemory) ListAll() ([]string, error)
- func (m *InMemory) Lock() error
- func (m *InMemory) Put(path string, data []byte) error
- func (m *InMemory) RLock() error
- func (m *InMemory) RUnlock() error
- func (m *InMemory) Rename(oldpath, newpath string) error
- func (m *InMemory) RenameNX(oldpath, newpath string) error
- func (m *InMemory) Unlock() error
- type RedisBackend
- func (b *RedisBackend) Close() error
- func (b *RedisBackend) Get(path string) ([]byte, error)
- func (b *RedisBackend) ListAll() ([]string, error)
- func (b *RedisBackend) Lock() error
- func (b *RedisBackend) Put(path string, data []byte) error
- func (b *RedisBackend) RLock() error
- func (b *RedisBackend) RUnlock() error
- func (b *RedisBackend) Rename(oldpath, newpath string) error
- func (b *RedisBackend) RenameNX(oldpath, newpath string) error
- func (b *RedisBackend) Unlock() error
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
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:
var ErrLockTimeout = errors.New("timed out while waiting for lock")
ErrLockTimeout errors returned by RedisBackend:
Functions ¶
func CheckDirectoryVersion ¶
CheckDirectoryVersion checks whether a key directory is of expected version.
Types ¶
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 (*InMemory) ListAll ¶
ListAll enumerates all paths currently stored. The paths are returned in lexicographical order.
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.