Documentation
¶
Overview ¶
Package client talks to a conch server over its socket.
Index ¶
- Variables
- func CopyProject(ctx context.Context, from, to *Client, projectID, path string) (proto.ProjectInfo, error)
- func EnsureServer(sockPath, logPath string) error
- type Client
- type Download
- func (d *Download) Close()
- func (d *Download) Dir() bool
- func (d *Download) Got() int64
- func (d *Download) Name() string
- func (d *Download) On(ssh string) *Download
- func (d *Download) Path() string
- func (d *Download) Run(ctx context.Context) (string, error)
- func (d *Download) Size() int64
- func (d *Download) Step(ctx context.Context) (bool, error)
- func (d *Download) Timeout() time.Duration
- type Move
- type Upload
- func (u *Upload) Close()
- func (u *Upload) Dir() bool
- func (u *Upload) Into(dir string, replace bool) *Upload
- func (u *Upload) Name() string
- func (u *Upload) On(ssh string) *Upload
- func (u *Upload) Path() string
- func (u *Upload) Run(ctx context.Context) (string, error)
- func (u *Upload) Sent() int
- func (u *Upload) Size() int
- func (u *Upload) Step(ctx context.Context) (bool, error)
- func (u *Upload) Timeout() time.Duration
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("connection to conch server closed")
ErrClosed is returned for calls on a closed connection.
Functions ¶
func CopyProject ¶ added in v0.2.0
func CopyProject(ctx context.Context, from, to *Client, projectID, path string) (proto.ProjectInfo, error)
CopyProject carries a project that has no origin — nothing there could clone it from — to another machine: its repository bundled by from, read back through this client, uploaded to to and made a project at path there, every branch and tag with the main checkout's branch checked out.
func EnsureServer ¶
EnsureServer makes sure a server is answering on sockPath, starting a detached `conch server` (logging to logPath) if needed. A socket left behind by a server that stopped serving is removed first, so a new server can bind it instead of the user being stuck with a conch that won't start.
Types ¶
type Client ¶
type Client struct {
Server proto.HelloResult
// Events receives server pushes in order. It is closed when the
// connection ends; Err then reports why.
Events chan proto.Message
// contains filtered or unexported fields
}
Client is a connection to one conch server.
func New ¶
func New(rw io.ReadWriteCloser, clientName string) (*Client, error)
New performs the hello handshake over an established stream, such as an SSH bridge to a remote server. The client owns rw from then on.
func (*Client) MissingCapabilities ¶
MissingCapabilities lists the capabilities in want that the server did not advertise.
func (*Client) Notify ¶
Notify sends a request without waiting for a reply. Notifications are delivered in the order Notify is called.
func (*Client) OlderBuild ¶ added in v0.2.0
OlderBuild lists what the server lacks of this build's capabilities — those it would have had it been this build, so anything listed means it is older. Capabilities a server may withhold at runtime are left out (proto.OptionalCapabilities).
type Download ¶ added in v0.1.9
type Download struct {
// contains filtered or unexported fields
}
Download copies a file or folder from the server's machine into a folder here, one chunk per Step so a caller can show progress. It arrives under a temporary name and takes its own only once whole; a folder is unpacked then. Without replace a name already taken here is kept and the copy is numbered, as a browser does.
func NewDownload ¶ added in v0.1.9
NewDownload prepares a download of remote (absolute, or from ~ there) into the folder dest here. It needs fs.transfer.v1.
func (*Download) Close ¶ added in v0.1.9
func (d *Download) Close()
Close drops what an unfinished download wrote and gives up on chunks still on their way. The server forgets its side once nobody reads it.
func (*Download) Name ¶ added in v0.1.9
Name is what it is called (known once started); Got and Size are bytes (a folder's are its pack's).
func (*Download) On ¶ added in v0.1.9
On brings it from the host the pane ssh is logged in to rather than the machine itself; remote is then a path on that host. It needs fs.ssh.v1.
func (*Download) Run ¶ added in v0.1.9
Run fetches every remaining chunk and returns where the copy is here.
type Move ¶ added in v0.1.4
type Move struct {
From, To *Client
ProjectID string // the project on From
Path string // the worktree on From
Target string // the project on To
History []string
// contains filtered or unexported fields
}
Move carries a worktree from one machine's server to another's, a step per call so a caller can show progress between them. The servers never talk to each other: the pack comes back through this client and goes up to the other machine as an upload.
func NewMove ¶ added in v0.1.4
NewMove prepares a move of the worktree whose history (newest first, from worktree.describe) tells the other machine which commits to skip.
func (*Move) Result ¶ added in v0.1.4
func (mv *Move) Result() proto.WorktreeUnpackResult
Result is the new worktree, once the move is done.
type Upload ¶ added in v0.1.1
type Upload struct {
// contains filtered or unexported fields
}
Upload sends a file to the server's uploads folder one chunk per Step, so a caller can show progress between chunks.
func OpenUpload ¶ added in v0.1.9
OpenUpload prepares an upload of the file or folder at path, read as it is sent rather than all at once. A folder is packed into a temporary file first. Close releases both.
func (*Upload) Close ¶ added in v0.1.9
func (u *Upload) Close()
Close releases the file OpenUpload opened, and a folder's pack, and gives up on chunks still on their way.
func (*Upload) Into ¶ added in v0.1.9
Into sends the upload to the folder dir there (absolute, or from ~) rather than the uploads folder; with replace, a file or folder already there by that name is written over. It needs fs.transfer.v1.
func (*Upload) On ¶ added in v0.1.9
On sends it to the host the pane ssh is logged in to rather than the machine itself; dir, from Into, is then a folder on that host. It needs fs.ssh.v1: a server without it would put the file on its own machine.
func (*Upload) Path ¶ added in v0.1.1
Path is the stored file's path on the server, once the upload is complete.
func (*Upload) Run ¶ added in v0.1.1
Run sends every remaining chunk and returns the stored file's path.