ctl

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ctl serves the control protocol of a workspace: one JSON object for each line over a unix socket. The fixtures in testdata/ctl at the repository root pin each operation and its errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(path string, uid, gid int) (net.Listener, error)

Listen binds the control socket before a caller mounts. The socket must lie in a directory that only the workspace of this mount can reach: the directory may not be open to others, and the socket is created 0660 and owned by uid and gid, so no other workspace or node process can connect.

Types

type ChangeEntry

type ChangeEntry struct {
	Path    string `json:"path"`
	Status  string `json:"status"`
	OldSHA  string `json:"old_sha,omitempty"`
	OldMode uint32 `json:"old_mode,omitempty"`
	OldSize int64  `json:"old_size,omitempty"`
	NewSHA  string `json:"new_sha,omitempty"`
	NewMode uint32 `json:"new_mode,omitempty"`
	Size    int64  `json:"size,omitempty"`
}

ChangeEntry is one file whose content in the view differs from the base tree. The SHAs are git blob names; an absent side has no SHA and mode 0.

type Code

type Code string

Code is the machine-readable cause of an error answer. The store codes of package api pass through, so the complete list is these and the codes of api.

const (
	CodeInvalidRequest   Code = "invalid_request"
	CodeUnknownOp        Code = "unknown_op"
	CodeLineTooLong      Code = "line_too_long"
	CodeStoreUnavailable Code = "store_unavailable"
	CodeInternal         Code = Code(api.CodeInternal)
	CodeObjectTooLarge   Code = Code(api.CodeObjectTooLarge)
)

type DirtyEntry

type DirtyEntry struct {
	Path   string `json:"path"`
	Kind   string `json:"kind"` // file, symlink, dir, deleted
	Exec   bool   `json:"exec,omitempty"`
	Opaque bool   `json:"opaque,omitempty"`
}

DirtyEntry is one path that the upper directory changes against the base tree.

type Server

type Server struct {
	Store     store.Store
	Cache     *store.Cache
	Workspace Workspace
	// MaxLine is the longest request line in bytes. Zero is 64 MiB. A longer line gets a line_too_long answer, and
	// the connection stays open.
	MaxLine int
	// contains filtered or unexported fields
}

Server serves the control protocol of one workspace.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

Serve answers the protocol on l until ctx ends. It then closes every open connection and returns after the handlers have ended.

type Stats

type Stats struct {
	BlobHits   int64 `json:"blob_hits"`
	BlobMisses int64 `json:"blob_misses"`
	TreeCalls  int64 `json:"tree_calls"`
}

Stats are the counters of the node cache.

type Workspace

type Workspace interface {
	BaseTree() string
	Token() (upperdir.Token, error)
	Dirty(ctx context.Context) ([]DirtyEntry, upperdir.Token, error)
	Changes(ctx context.Context) ([]ChangeEntry, upperdir.Token, error)
	Stats() Stats
}

Workspace is the part of the protocol that the lower layer answers: the change token, the dirty set and the changes of the upper directory against the base tree.

Jump to

Keyboard shortcuts

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