state

package
v0.50.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.50.0

type Option func(*cfg)

Option allows setting optional parameters of the TokenStore.

func WithEncryptionKey added in v0.50.0

func WithEncryptionKey(k *ecdsa.PrivateKey) Option

WithEncryptionKey return an option to encrypt private session keys using provided private key.

func WithLogger added in v0.50.0

func WithLogger(v *zap.Logger) Option

WithLogger returns an option to specify logger.

func WithTimeout added in v0.50.0

func WithTimeout(v time.Duration) Option

WithTimeout returns option to specify database connection timeout.

type PersistentStorage

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

PersistentStorage is a wrapper around persistent K:V db that provides thread safe functions to set and fetch state variables of the Inner Ring and Storage applications and optionally allows creating (storing), retrieving and expiring (removing) session tokens.

func NewPersistentStorage

func NewPersistentStorage(path string, withSessionStorage bool, opts ...Option) (*PersistentStorage, error)

NewPersistentStorage creates a new instance of a storage with 0o600 rights.

func (PersistentStorage) Bytes added in v0.39.0

func (p PersistentStorage) Bytes(key []byte) (res []byte, err error)

Bytes reads binary value by specified key. Returns nil if value is missing.

func (PersistentStorage) Close

func (p PersistentStorage) Close() error

Close closes persistent database instance.

func (PersistentStorage) Delete added in v0.44.0

func (p PersistentStorage) Delete(key []byte) error

func (PersistentStorage) GetToken added in v0.50.0

func (p PersistentStorage) GetToken(ownerID user.ID, tokenID []byte) (t *session.PrivateToken)

GetToken returns private token corresponding to the given identifiers.

Returns nil is there is no element in storage.

func (PersistentStorage) MigrateOldTokenStorage added in v0.50.0

func (p PersistentStorage) MigrateOldTokenStorage(oldPath string) error

func (PersistentStorage) RemoveOldTokens added in v0.50.0

func (p PersistentStorage) RemoveOldTokens(epoch uint64)

RemoveOldTokens removes all tokens expired since provided epoch.

func (PersistentStorage) SetBytes added in v0.39.0

func (p PersistentStorage) SetBytes(key []byte, value []byte) error

SetBytes saves binary value in the storage by specified key.

func (PersistentStorage) SetUInt32

func (p PersistentStorage) SetUInt32(key []byte, value uint32) error

SetUInt32 sets a uint32 value in the storage.

func (PersistentStorage) Store added in v0.50.0

func (p PersistentStorage) Store(sk ecdsa.PrivateKey, usr user.ID, id []byte, exp uint64) error

Store saves parameterized private key in the underlying Bolt database. Private keys are encrypted if token store has been configured to.

func (PersistentStorage) UInt32

func (p PersistentStorage) UInt32(key []byte) (n uint32, err error)

UInt32 returns a uint32 value from persistent storage. If the value does not exist, returns 0.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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