persist

package
v0.0.9-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package persist enables persistent storage of the execution state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FsPersister

type FsPersister struct {
	State  *state.State
	Memory *cache.Cache
	// contains filtered or unexported fields
}

FsPersister is an implementation of Persister that saves state to the file system.

func NewFsPersister

func NewFsPersister(dir string) *FsPersister

NewFsPersister creates a new FsPersister.

The filesystem store will be at the given directory. The directory must exist.

func (*FsPersister) Deserialize

func (p *FsPersister) Deserialize(b []byte) error

GetState implements the Persister interface.

func (*FsPersister) GetMemory

func (p *FsPersister) GetMemory() cache.Memory

GetState implements the Persister interface.

func (*FsPersister) GetState

func (p *FsPersister) GetState() *state.State

GetState implements the Persister interface.

func (*FsPersister) Load

func (p *FsPersister) Load(key string) error

GetState implements the Persister interface.

func (*FsPersister) Save

func (p *FsPersister) Save(key string) error

GetState implements the Persister interface.

func (*FsPersister) Serialize

func (p *FsPersister) Serialize() ([]byte, error)

GetState implements the Persister interface.

func (*FsPersister) WithContent

func (p *FsPersister) WithContent(st *state.State, ca *cache.Cache) *FsPersister

WithContent sets a current State and Cache object.

This method is normally called before Serialize / Save.

type Persister

type Persister interface {
	Serialize() ([]byte, error) // Output serializes representation of the state.
	Deserialize(b []byte) error // Restore state from a serialized state.
	Save(key string) error      // Serialize and commit the state representation to persisted storage.
	Load(key string) error      // Load the state representation from persisted storage and Deserialize.
	GetState() *state.State     // Get the currently loaded State object.
	GetMemory() cache.Memory    // Get the currently loaded Cache object.
}

Persister interface defines the methods needed for a component that can store the execution state to a storage location.

Jump to

Keyboard shortcuts

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