local

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Name = "local"

Name is the registered backend name.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey() (string, error)

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

func Open(o Options) (*polign.Backend, error)

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 ReadKey

func ReadKey(dir string) (string, error)

ReadKey reads the directory's key file.

func Resolve

func Resolve(dir string) (string, error)

Resolve makes dir absolute, expanding a leading ~; empty means Home().

func ServerPath

func ServerPath(explicit string) (string, error)

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.

func ValidKey

func ValidKey(key string) bool

ValidKey reports whether key has the shape GenerateKey makes.

func WriteKey

func WriteKey(dir, key string) error

WriteKey writes the directory's key file, readable by the owner only.

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.

func Ensure

func Ensure(ctx context.Context, o Options) (Connection, error)

Ensure starts the directory's server if it is not running and returns how to reach it. It is safe to call from several processes at once: they take turns on a lock file, and the second finds the first one's server.

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.

Jump to

Keyboard shortcuts

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