Documentation
¶
Overview ¶
Package local is the backend Recall uses when nothing names a database: a polign_db that Recall runs itself, kept in a directory on this machine.
The first process to open a directory starts a polign-server for it on a free loopback port, with a generated key only this directory knows, and leaves it running; later processes find it through the runtime file the server writes. Nothing listens beyond this host. The server needs polign-server beside the recall binary or on PATH, which pip and Homebrew install with recall.
Importing this package registers it as the "local" backend:
import _ "github.com/Polign/recall/backend/local"
b, err := recall.OpenBackend("local", recall.BackendOptions{URL: "~/agent-memory"})
An empty URL means Home(), where every agent on the machine shares one memory. The one option is ?server=/path/to/polign-server.
Index ¶
- Constants
- func GenerateKey() (string, error)
- func Home() string
- func LegacyHome() string
- func Open(o Options) (*polign.Backend, error)
- func ReadKey(dir string) (string, error)
- func Resolve(dir string) (string, error)
- func ServerPath(explicit string) (string, error)
- func ValidKey(key string) bool
- func WriteKey(dir, key string) error
- type Connection
- type Options
Constants ¶
const Name = "local"
Name is the registered backend name.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey makes a key in the shape polign-server accepts from -bootstrap-key-file: plgn_<16 hex>_<64 hex>. The server stays the authority and refuses to start on a key it cannot parse.
func Home ¶
func Home() string
Home is the directory Recall keeps its own configuration and, when nothing names a database, its memory in: $RECALL_HOME, else $XDG_DATA_HOME/recall, else ~/.local/share/recall, with the spellings before 0.23.0 ($POLIGN_RECALL_HOME, and a setup saved in ~/.config/polign/recall) still honored. See recallhome.Home.
func LegacyHome ¶
func LegacyHome() string
LegacyHome is where setups before 0.23.0 lived, ~/.config/polign/recall.
func Open ¶
Open makes sure the directory's server is running and returns a backend connected to it. Unlike the other backends' constructors it may start a process and wait for it, which takes up to a few seconds the first time.
func ServerPath ¶
ServerPath finds the polign-server to run: explicit when given, else the one beside the running binary (a pip environment, Homebrew, a release archive), else the first on PATH. polign_db ships it; Recall does not.
Types ¶
type Connection ¶
type Connection struct {
// URL is the server's HTTP address on the loopback interface.
URL string
// Key is the API key the server was started with.
Key string
// Dir is the directory, made absolute.
Dir string
}
Connection is where the running server listens and the key it accepts.
type Options ¶
type Options struct {
// Dir is the directory. Empty means Home(). A leading ~ is the user's
// home directory.
Dir string
// Server is the polign-server executable. Empty means the one beside
// the running binary, then the first on PATH.
Server string
}
Options say which directory holds the database and which polign-server runs it.