store

package
v0.0.0-...-65a760c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package store defines the permanent storage service.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingCmd = errors.New("no matching command line")

ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query completes with no result.

View Source
var ErrNoSharedVar = errors.New("no such shared variable")

ErrNoSharedVar is returned by Store.SharedVar when there is no such variable.

View Source
var NoBlacklist = map[string]struct{}{}

NoBlacklist is an empty blacklist, to be used in GetDirs.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Text string
	Seq  int
}

Cmd is an entry in the command history.

type DBStore

type DBStore interface {
	Store

	Waits() *sync.WaitGroup
	Close() error
}

DBStore is the permanent storage backend for elvish. It is not thread-safe. In particular, the store may be closed while another goroutine is still accessing the To prevent bad things from happening, every time the main goroutine spawns a new goroutine to operate on the store, it should call Waits.Add(1) in the main goroutine before spawning another goroutine, and call Waits.Done() in the spawned goroutine after the operation is finished.

func MustGetTempStore

func MustGetTempStore() (DBStore, func())

MustGetTempStore returns a Store backed by a temporary file, and a cleanup function that should be called when the Store is no longer used.

func NewStore

func NewStore(dbname string) (DBStore, error)

NewStore creates a new Store from the given file.

func NewStoreFromDB

func NewStoreFromDB(db *bolt.DB) (DBStore, error)

NewStoreFromDB creates a new Store from a bolt DB.

type Dir

type Dir struct {
	Path  string
	Score float64
}

Dir is an entry in the directory history.

type Store

type Store interface {
	NextCmdSeq() (int, error)
	AddCmd(text string) (int, error)
	DelCmd(seq int) error
	Cmd(seq int) (string, error)
	Cmds(from, upto int) ([]string, error)
	CmdsWithSeq(from, upto int) ([]Cmd, error)
	NextCmd(from int, prefix string) (Cmd, error)
	PrevCmd(upto int, prefix string) (Cmd, error)

	AddDir(dir string, incFactor float64) error
	DelDir(dir string) error
	Dirs(blacklist map[string]struct{}) ([]Dir, error)

	SharedVar(name string) (string, error)
	SetSharedVar(name, value string) error
	DelSharedVar(name string) error
}

Store is an interface satisfied by the storage service.

Jump to

Keyboard shortcuts

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