Documentation
¶
Index ¶
- Constants
- Variables
- func Reload(ctx context.Context, sockPath string, configPath string) (bool, []string, error)
- type OpenCountsProvider
- type OpenCountsRequest
- type OpenCountsResponse
- type OpenFileID
- type OpenStat
- type ReloadProvider
- type ReloadRequest
- type ReloadResponse
- type RemoteError
- type Server
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.