daemonctl

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpOpenCounts is the request op for querying open counts.
	OpOpenCounts = "open_counts"

	// OpReload is the request op for hot-reloading mount-scoped config.
	OpReload = "reload"
)

Variables

View Source
var (
	// ErrDialDaemonSocket indicates the client failed to connect to daemon.sock.
	ErrDialDaemonSocket = errkind.SentinelError("daemon socket dial failed")

	// ErrRemote indicates the daemon responded with a non-empty error string.
	ErrRemote = errkind.SentinelError("daemonctl remote error")
)

Functions

func Reload

func Reload(ctx context.Context, sockPath string, configPath string) (bool, []string, error)

Reload requests that the daemon reloads its mount-scoped configuration.

Types

type OpenCountsProvider

type OpenCountsProvider interface {
	OpenCounts(ctx context.Context, files []OpenFileID) ([]OpenStat, error)
}

OpenCountsProvider exposes open-count information to the control server.

type OpenCountsRequest

type OpenCountsRequest struct {
	Op    string       `json:"op"`
	Files []OpenFileID `json:"files"`
}

OpenCountsRequest is a daemon.sock request.

type OpenCountsResponse

type OpenCountsResponse struct {
	Files []OpenStat `json:"files"`
	Error string     `json:"error,omitempty"`
}

OpenCountsResponse is a daemon.sock response.

type OpenFileID

type OpenFileID struct {
	StorageID string `json:"storage_id"`
	Dev       uint64 `json:"dev"`
	Ino       uint64 `json:"ino"`
}

OpenFileID uniquely identifies a file on a storage backend.

Dev+Ino come from syscall.Stat_t and are used to identify hardlinks correctly. StorageID scopes the ID to the configured storage root.

type OpenStat

type OpenStat struct {
	OpenFileID
	OpenCount      int64 `json:"open_count"`
	OpenWriteCount int64 `json:"open_write_count"`
}

OpenStat is an open-count snapshot for a file.

func QueryOpenCounts

func QueryOpenCounts(ctx context.Context, sockPath string, files []OpenFileID) ([]OpenStat, error)

QueryOpenCounts queries daemon.sock for open counts.

type ReloadProvider

type ReloadProvider interface {
	Reload(ctx context.Context, configPath string) (bool, []string, error)
}

ReloadProvider applies a config reload request.

type ReloadRequest

type ReloadRequest struct {
	Op         string `json:"op"`
	ConfigPath string `json:"config_path"`
}

ReloadRequest is a daemon.sock request.

type ReloadResponse

type ReloadResponse struct {
	Changed       bool     `json:"changed"`
	ChangedFields []string `json:"changed_fields,omitempty"`
	Error         string   `json:"error,omitempty"`
}

ReloadResponse is a daemon.sock response.

type RemoteError

type RemoteError struct {
	Msg string
}

RemoteError wraps an error returned by the daemon over the control socket.

Callers can match it via errors.Is(err, ErrRemote).

func (*RemoteError) Error

func (e *RemoteError) Error() string

func (*RemoteError) Is

func (e *RemoteError) Is(target error) bool

type Server

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

Server is a unix domain socket server for daemon control/status queries.

func StartServer

func StartServer(ctx context.Context, sockPath string, provider OpenCountsProvider, log zerolog.Logger) (*Server, error)

StartServer starts a unix domain socket server at sockPath.

func (*Server) Close

func (s *Server) Close() error

Close shuts down the server and removes the socket file.

Jump to

Keyboard shortcuts

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