src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/daemon/daemondefs/daemondefs.go (about)

     1  // Package daemondefs contains definitions used for the daemon.
     2  //
     3  // It is a separate package so that packages that only depend on the daemon
     4  // API does not need to depend on the concrete implementation.
     5  package daemondefs
     6  
     7  import (
     8  	"io"
     9  
    10  	"src.elv.sh/pkg/store/storedefs"
    11  )
    12  
    13  // Client represents a daemon client.
    14  type Client interface {
    15  	storedefs.Store
    16  
    17  	ResetConn() error
    18  	Close() error
    19  
    20  	Pid() (int, error)
    21  	SockPath() string
    22  	Version() (int, error)
    23  }
    24  
    25  // ActivateFunc is a function that activates a daemon client, possibly by
    26  // spawning a new daemon and connecting to it.
    27  type ActivateFunc func(stderr io.Writer, spawnCfg *SpawnConfig) (Client, error)
    28  
    29  // SpawnConfig keeps configurations for spawning the daemon.
    30  type SpawnConfig struct {
    31  	// DbPath is the path to the database.
    32  	DbPath string
    33  	// SockPath is the path to the socket on which the daemon will serve
    34  	// requests.
    35  	SockPath string
    36  	// RunDir is the directory in which to place the daemon log file.
    37  	RunDir string
    38  }