elvish: github.com/elves/elvish/pkg/store Index | Files

package store

import "github.com/elves/elvish/pkg/store"

Package store defines the permanent storage service.

Index

Package Files

buckets.go cmd.go db_store.go dir.go shared_var.go store.go temp_store.go

Variables

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

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

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

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

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

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

type Cmd Uses

type Cmd struct {
    Text string
    Seq  int
}

Cmd is an entry in the command history.

type DBStore Uses

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 Uses

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 Uses

func NewStore(dbname string) (DBStore, error)

NewStore creates a new Store from the given file.

func NewStoreFromDB Uses

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

NewStoreFromDB creates a new Store from a bolt DB.

type Dir Uses

type Dir struct {
    Path  string
    Score float64
}

Dir is an entry in the directory history.

type Store Uses

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.

Package store imports 12 packages (graph) and is imported by 9 packages. Updated 2020-03-28. Refresh now. Tools for package owners.