Documentation
¶
Index ¶
- Constants
- Variables
- func BuildNotice(daemonBuild string) string
- func EnsureRunning(ctx context.Context, port int) error
- func FillBindingToken(cfg *config.Config) error
- func LocalDialConfig(ctx context.Context, cfg *config.Config, kind string) (agui.DialConfig, error)
- func LocalTokenFile() string
- func PIDFile() string
- func Reachable(port int) bool
- func RunningPID() string
- func RunningPIDHint() string
- func Stop(ctx context.Context) (int, error)
- type Client
Constants ¶
const AckAttrBuild = agentinfra.AttrBuild
AckAttrBuild is the field of its hello ack a daemon declares its Build in.
Variables ¶
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.
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
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 ¶
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
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
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
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
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
DialLocal connects a client of kind to the daemon cfg describes, over its TLS when it serves any.