leyline

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package leyline provides Go bindings to the ley-line C FFI.

The actual implementation requires the "leyline" build tag and a locally built libleyline_fs.a. See client.go for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverOrStart

func DiscoverOrStart() (string, error)

DiscoverOrStart finds a running ley-line daemon socket, or auto-starts a managed daemon subprocess if the leyline binary is on PATH.

The managed daemon uses ~/.mache/ as its data directory:

~/.mache/default.arena  — arena file
~/.mache/default.ctrl   — control block
~/.mache/default.sock   — UDS socket (what we connect to)
~/.mache/mount/         — FUSE/NFS mount point

The subprocess is killed when the mache process exits (via atexit cleanup registered on first spawn). Only one managed daemon per process.

func DiscoverSocket

func DiscoverSocket() (string, error)

DiscoverSocket finds the ley-line socket path by checking:

  1. LEYLINE_SOCKET environment variable
  2. ~/.mache/default.sock (well-known kiln deployment path)

Returns the path and nil error if a socket file exists, or an error if no socket can be found. Does NOT auto-start a daemon.

func StopManaged

func StopManaged()

StopManaged kills the auto-spawned leyline daemon, if any. Safe to call multiple times. Called automatically by cleanup hooks.

Types

type SocketClient

type SocketClient struct {
	// contains filtered or unexported fields
}

SocketClient communicates with a running ley-line daemon over its Unix domain control socket ({ctrl}.sock).

func DialSocket

func DialSocket(sockPath string) (*SocketClient, error)

DialSocket connects to the ley-line control socket at sockPath. The socket path is typically derived from the control path: e.g. /tmp/leyline.ctrl → /tmp/leyline.sock

func (*SocketClient) Close

func (c *SocketClient) Close() error

Close closes the underlying connection. Safe to call multiple times.

func (*SocketClient) Query

func (c *SocketClient) Query(sql string) ([][]any, error)

Query runs a SQL query against the active arena buffer via the `query` op. Returns the rows as [][]any.

func (*SocketClient) SendOp

func (c *SocketClient) SendOp(req map[string]any) (map[string]any, error)

SendOp sends a JSON request and reads the JSON response. Both are line-delimited (newline-terminated JSON).

func (*SocketClient) SetDeadline

func (c *SocketClient) SetDeadline(t time.Time) error

SetDeadline sets the read/write deadline on the underlying connection.

func (*SocketClient) Tool

func (c *SocketClient) Tool(name string, args map[string]any) (map[string]any, error)

Tool invokes a named tool with the given args via the `tool` op. Returns the full response map on success.

Jump to

Keyboard shortcuts

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