daemon

package
v0.268.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 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

Index

Constants

View Source
const AckAttrBuild = agentinfra.AttrBuild

AckAttrBuild is the field of its hello ack a daemon declares its Build in.

Variables

View Source
var Build = sync.OnceValue(func() string {
	exe, err := os.Executable()
	if err != nil {
		return ""
	}
	return fileSHA256(exe)
})

Build identifies the running binary by the SHA-256 of its executable, so a chat tells a daemon of another build apart even when both are dev builds of one version. It is "" when the executable cannot be read.

View Source
var ErrNoBinding = errors.New("the daemon binding is off: enable daemon.binding in daemon.yaml")

ErrNoBinding is the refusal to dial a daemon whose binding is off.

Functions

func BuildNotice added in v0.268.0

func BuildNotice(daemonBuild string) string

BuildNotice says that a daemon declaring daemonBuild runs another build than this binary and names it to stop, and is "" for the same build. A daemon that declares none predates the declaration, so it is another build too.

func EnsureRunning

func EnsureRunning(ctx context.Context, port int) error

EnsureRunning makes an infer daemon serve its binding on port, starting one in the background when nothing listens there. The daemon's own pid lock makes a redundant start exit, so callers never coordinate, and the wait covers a daemon already on its way. A daemon still shutting down holds that lock, so the start is retried until it is gone.

func FillBindingToken added in v0.239.0

func FillBindingToken(cfg *config.Config) error

FillBindingToken gives an enabled binding with neither a token nor client certificates this machine's local token, created on first use, so the daemon and its local clients agree on one without daemon.yaml.

func LocalDialConfig added in v0.239.0

func LocalDialConfig(ctx context.Context, cfg *config.Config, kind string) (agui.DialConfig, error)

LocalDialConfig is how a client of kind dials the daemon cfg describes: the binding's address and token, or this machine's local token the daemon also uses when daemon.yaml sets none, over TLS with this machine's client certificate when the binding serves one.

func LocalTokenFile added in v0.239.0

func LocalTokenFile() string

LocalTokenFile keeps the binding token this machine's daemon and its local clients share when daemon.yaml configures none.

func PIDFile added in v0.268.0

func PIDFile() string

PIDFile is where the running daemon keeps its pid, under the lock that keeps it the only daemon of this user.

func Reachable added in v0.268.0

func Reachable(port int) bool

Reachable reports whether something accepts TCP on port, such as a daemon serving its binding there.

func RunningPID added in v0.268.0

func RunningPID() string

RunningPID is the pid the running daemon recorded, "" when none did.

func RunningPIDHint added in v0.268.0

func RunningPIDHint() string

RunningPIDHint names the running daemon's pid in a sentence, " (pid 4242)", and is "" when it is unknown.

func Stop added in v0.268.0

func Stop(ctx context.Context) (int, error)

Stop stops this user's running daemon and returns its pid, 0 when none runs. A pid counts only while a daemon holds the pid file's lock, since the file a crashed daemon left may name a process that reused its pid. shortcut: windows has no SIGTERM, so the daemon is killed and its one-shot runs outlive it, send a stop frame over the binding once windows needs one.

Types

type Client added in v0.268.0

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

Client is one connection of a CLI command to the local daemon: it sends frames and reads the answers back by type.

func DialLocal added in v0.268.0

func DialLocal(ctx context.Context, cfg *config.Config, kind string) (*Client, error)

DialLocal connects a client of kind to the daemon cfg describes, over its TLS when it serves any.

func (*Client) Attach added in v0.268.0

func (c *Client) Attach(*agui.Conn)

func (*Client) Close added in v0.268.0

func (c *Client) Close()

func (*Client) Detach added in v0.268.0

func (c *Client) Detach(*agui.Conn)

func (*Client) Handle added in v0.268.0

func (c *Client) Handle(_ *agui.Conn, frame []byte)

func (*Client) Next added in v0.268.0

func (c *Client) Next(ctx context.Context, types ...string) (map[string]any, error)

Next returns the next frame of one of the types, or the error a RUN_ERROR carries.

func (*Client) Send added in v0.268.0

func (c *Client) Send(frame any) error

Jump to

Keyboard shortcuts

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