fskeystore

package
v1.10.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyExists = fmt.Errorf("key by that name already exists, refusing to overwrite")

ErrKeyExists is returned when writing a key would overwrite an existing key

View Source
var ErrKeyFmt = fmt.Errorf("key has invalid format")

ErrKeyFmt is returned when the key's format is invalid

View Source
var ErrNoSuchKey = fmt.Errorf("no key by the given name was found")

ErrNoSuchKey is returned if a key of the given name is not found in the store

Functions

This section is empty.

Types

type FSKeystore

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

FSKeystore is a keystore backed by files in a given directory stored on disk.

func NewFSKeystore

func NewFSKeystore(dir string) (*FSKeystore, error)

NewFSKeystore returns a new filesystem keystore at directory `dir`

func (*FSKeystore) Delete

func (ks *FSKeystore) Delete(name string) error

Delete removes a key from the Keystore

func (*FSKeystore) Get

func (ks *FSKeystore) Get(name string) ([]byte, error)

Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey otherwise.

func (*FSKeystore) Has

func (ks *FSKeystore) Has(name string) (bool, error)

Has returns whether or not a key exists in the Keystore

func (*FSKeystore) List

func (ks *FSKeystore) List() ([]string, error)

List returns a list of key identifiers

func (*FSKeystore) Put

func (ks *FSKeystore) Put(name string, data []byte) error

Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists

type Keystore

type Keystore interface {
	// Has returns whether or not a key exist in the Keystore
	Has(string) (bool, error)
	// Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists
	Put(string, []byte) error
	// Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey
	// otherwise.
	Get(string) ([]byte, error)
	// Delete removes a key from the Keystore
	Delete(string) error
	// List returns a list of key identifier
	List() ([]string, error)
}

Keystore provides a key management interface

type MemKeystore

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

MemKeystore is a keystore backed by an in-memory map

func NewMemKeystore

func NewMemKeystore() *MemKeystore

NewMemKeystore returns a new map-based keystore

func (*MemKeystore) Delete

func (mk *MemKeystore) Delete(k string) error

Delete removes a key from the map

func (*MemKeystore) Get

func (mk *MemKeystore) Get(k string) ([]byte, error)

Get retrieves a key from the map if it exists, else it returns ErrNoSuchKey

func (*MemKeystore) Has

func (mk *MemKeystore) Has(k string) (bool, error)

Has returns whether or not a key exists in the keystore map

func (*MemKeystore) List

func (mk *MemKeystore) List() ([]string, error)

List returns a list of key identifiers in random order

func (*MemKeystore) Put

func (mk *MemKeystore) Put(k string, b []byte) error

Put stores a key in the map, if a key with the same name already exists, returns ErrKeyExists

type MutexKeystore

type MutexKeystore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MutexKeystore contains a child keystore and a mutex. used for coarse sync

func MutexWrap

func MutexWrap(k Keystore) *MutexKeystore

MutexWrap constructs a keystore with a coarse lock around the entire keystore, for every single operation

func (*MutexKeystore) Children

func (mk *MutexKeystore) Children() []Keystore

Children implements Shim

func (*MutexKeystore) Delete

func (mk *MutexKeystore) Delete(k string) error

Delete implements Keystore.Delete

func (*MutexKeystore) Get

func (mk *MutexKeystore) Get(k string) ([]byte, error)

Get implements Keystore.Get

func (*MutexKeystore) Has

func (mk *MutexKeystore) Has(k string) (bool, error)

Has implements Keystore.Has

func (*MutexKeystore) List

func (mk *MutexKeystore) List() ([]string, error)

List implements Keystore.List

func (*MutexKeystore) Put

func (mk *MutexKeystore) Put(k string, data []byte) error

Put implements Keystore.Put

Jump to

Keyboard shortcuts

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