api

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: 1 Imported by: 0

Documentation

Overview

Package api defines abstract backend interface.

Index

Constants

View Source
const PathSeparator = "/"

PathSeparator used in key paths.

Variables

View Source
var (
	ErrNotExist    = errors.New("key path does not exist")
	ErrExist       = errors.New("key path already exists")
	ErrInvalidPath = errors.New("invalid key path")
)

Errors returned by filesystem.Backend:

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Get data at given path.
	// Returns ErrNotExist if path does not exist.
	Get(path string) ([]byte, error)
	// Put data at given path.
	// Returns ErrExist if path already exists.
	Put(path string, data []byte) error

	// ListAll enumerates all paths currently stored.
	// The paths are returned in lexicographical order.
	ListAll() ([]string, error)

	// Rename oldpath into newpath atomically.
	// Replaces newpath if it already exists.
	// Returns ErrNotExist if oldpath does not exist.
	Rename(oldpath, newpath string) error
	// Rename oldpath into newpath non-destructively.
	// Returns ErrExist if newpath already exists.
	// Returns ErrNotExist if oldpath does not exist.
	RenameNX(oldpath, newpath string) error

	// Lock acquires an exclusive lock on the store, suitable for writing.
	// This call blocks until the lock is acquired.
	// It can also deadlock if you already hold the lock.
	Lock() error
	// RLock acquires a shared lock on the store, suitable for reading.
	// This call blocks until the lock is acquired.
	RLock() error
	// Unlock releases the exclusive lock currently held by the process.
	// It is an error to call it without calling Lock() first.
	Unlock() error
	// RUnlock releases the shared lock currently held by the process.
	// It is an error to call it without calling RLock() first.
	RUnlock() error

	// Close this backend instance, freeing any associated resources.
	// This implicitly unlocks the store if any locks are held.
	Close() error
}

Backend defines how KeyStore persists internal key data.

Directories

Path Synopsis
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