daemon Package
Last updated
This page lists the exported API of
core/daemon: lifecycle, data methods, wire types, and errors.Lifecycle
- func New(dir string, apiKey ...string) (*Daemon, error)
- func (d *Daemon) Start() error
- func (d *Daemon) Stop() error
- func (d *Daemon) Close() error
- func (d *Daemon) Mode() Mode
- func (d *Daemon) Socket() string
- func (d *Daemon) Store() *store.Store
- type Mode int
- const (
- ModeServer Mode = iota
- ModeClient
- )
Store() is nil in client mode. Lifecycle behavior per mode is in Socket Daemon.Data
- func (d *Daemon) Get(ctx context.Context, db int, key string) (*Record, error)
- func (d *Daemon) Entries(ctx context.Context, db int, pattern string, option *ScanOption) ([]Record, error)
- func (d *Daemon) Set(ctx context.Context, db int, key string, content any, expireAt *int64) error
- func (d *Daemon) SetVector(ctx context.Context, db int, key string, content any, expireAt *int64) error
- func (d *Daemon) Del(ctx context.Context, db int, keys ...string) (int, error)
- func (d *Daemon) TTL(ctx context.Context, db int, key string) (int64, error)
- func (d *Daemon) Expire(ctx context.Context, db int, ttl int64, keys ...string) (int, error)
- func (d *Daemon) Keys(ctx context.Context, db int, pattern string, limit, page int) (*ListResult, error)
- func (d *Daemon) VSearch(ctx context.Context, db int, text, pattern string, limit int) ([]string, error)
- func (d *Daemon) HasEmbedder(ctx context.Context) (bool, error)
Types and Errors
- type ScanOption struct {
- Contains string
- After int64
- Limit int
- }
- type Record struct {
- DB int `json:"db"`
- Key string `json:"key"`
- Type string `json:"type"`
- Content json.RawMessage `json:"content,omitempty"`
- CreatedAt int64 `json:"created_at,omitempty"`
- UpdatedAt *int64 `json:"updated_at,omitempty"`
- ExpireAt *int64 `json:"expire_at,omitempty"`
- }
- func (r *Record) Value() (string, error)
- type ListResult struct {
- DB int `json:"db"`
- Page int `json:"page"`
- Limit int `json:"limit"`
- Total int `json:"total"`
- Keys []string `json:"keys"`
- }
- var (
- ErrAlreadyRunning = errors.New("another daemon is serving this socket")
- ErrNotFound = errors.New("not found")
- ErrBadRequest = errors.New("bad request")
- ErrNoEmbedder = store.ErrNoEmbedder
- )
Record and ListResult are the wire types themselves. Content holds raw JSON for json/int/float/bool values that are valid JSON, and a JSON string otherwise; Value() returns the stored text either way.