src.elv.shsrc.elv.sh/pkg/daemon Index | Files | Directories

package daemon

import "src.elv.sh/pkg/daemon"

Package daemon implements a service for mediating access to the data store, and its client.

Most RPCs exposed by the service correspond to the methods of Store in the store package and are not documented here.

Index

Variables

var (
	// ErrDaemonUnreachable is returned when the daemon cannot be reached after
	// several retries.
	ErrDaemonUnreachable = errors.New("daemon offline")
)

Functions

func Activate

func Activate(stderr io.Writer, spawnCfg *daemondefs.SpawnConfig) (daemondefs.Client, error)

Activate returns a daemon client, either by connecting to an existing daemon, or spawning a new one. It always returns a non-nil client, even if there was an error.

func NewClient

func NewClient(sockPath string) daemondefs.Client

NewClient creates a new Client instance that talks to the socket. Connection creation is deferred to the first request.

func Serve

func Serve(sockpath, dbpath string, opts ServeOpts) int

Serve runs the daemon service, listening on the socket specified by sockpath and serving data from dbpath until all clients have exited. See doc for ServeOpts for additional options.

Types

type Program

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

Program is the daemon subprogram.

func (*Program) RegisterFlags

func (p *Program) RegisterFlags(fs *prog.FlagSet)

func (*Program) Run

func (p *Program) Run(fds [3]*os.File, args []string) error

type ServeOpts

type ServeOpts struct {
	// If not nil, will be closed when the daemon is ready to serve requests.
	Ready chan<- struct{}
	// Causes the daemon to abort if closed or sent any date. If nil, Serve will
	// set up its own signal channel by listening to SIGINT and SIGTERM.
	Signals <-chan os.Signal
	// If not nil, overrides the response of the Version RPC.
	Version *int
}

ServeOpts keeps options that can be passed to Serve.

Source Files

activate.go client.go server.go service.go sys_unix.go

Directories

PathSynopsis
pkg/daemon/daemondefsPackage daemondefs contains definitions used for the daemon.
pkg/daemon/internal
Version
v0.21.0 (latest)
Published
Aug 13, 2024
Platform
linux/amd64
Imports
19 packages
Last checked
6 hours ago

Tools for package owners.