client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 20 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 client talks to a conch server over its socket.

Index

Constants

This section is empty.

Variables

View Source
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

func EnsureServer(sockPath, logPath string) error

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 Dial

func Dial(sockPath, clientName string) (*Client, error)

Dial connects to the server socket and performs the hello handshake.

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) Call

func (c *Client) Call(ctx context.Context, method string, params, out any) error

Call sends a request and decodes the result into out (which may be nil).

func (*Client) Close

func (c *Client) Close() error

Close ends the connection.

func (*Client) Err

func (c *Client) Err() error

Err returns why the connection ended, or nil while it is open.

func (*Client) MissingCapabilities

func (c *Client) MissingCapabilities(want []string) []string

MissingCapabilities lists the capabilities in want that the server did not advertise.

func (*Client) Notify

func (c *Client) Notify(method string, params any)

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

func (c *Client) OlderBuild() []string

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

func NewDownload(c *Client, remote, dest string, replace bool) *Download

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) Dir added in v0.1.9

func (d *Download) Dir() bool

Dir reports whether a folder is coming, once started.

func (*Download) Got added in v0.1.9

func (d *Download) Got() int64

func (*Download) Name added in v0.1.9

func (d *Download) Name() string

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

func (d *Download) On(ssh string) *Download

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) Path added in v0.1.9

func (d *Download) Path() string

Path is where the copy is here, once whole.

func (*Download) Run added in v0.1.9

func (d *Download) Run(ctx context.Context) (string, error)

Run fetches every remaining chunk and returns where the copy is here.

func (*Download) Size added in v0.1.9

func (d *Download) Size() int64

func (*Download) Step added in v0.1.9

func (d *Download) Step(ctx context.Context) (bool, error)

Step fetches the next chunk and reports whether the download is whole and in place.

func (*Download) Timeout added in v0.1.9

func (d *Download) Timeout() time.Duration

Timeout is how long the next step may take: a folder is packed before the first chunk can be read.

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

func NewMove(from, to *Client, projectID, path, target string, history []string) *Move

NewMove prepares a move of the worktree whose history (newest first, from worktree.describe) tells the other machine which commits to skip.

func (*Move) Progress added in v0.1.4

func (mv *Move) Progress() string

Progress says what the move is doing, for a status line.

func (*Move) Result added in v0.1.4

func (mv *Move) Result() proto.WorktreeUnpackResult

Result is the new worktree, once the move is done.

func (*Move) Run added in v0.1.4

Run takes every remaining step, each within its own timeout.

func (*Move) Step added in v0.1.4

func (mv *Move) Step(ctx context.Context) (bool, error)

Step runs the next step and reports whether the worktree has arrived.

func (*Move) Timeout added in v0.1.4

func (mv *Move) Timeout() time.Duration

Timeout is how long the next step may take: packing and unpacking a big branch run git for a while.

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 NewUpload added in v0.1.1

func NewUpload(c *Client, name string, data []byte) *Upload

NewUpload prepares an upload of data under name.

func OpenUpload added in v0.1.9

func OpenUpload(c *Client, path string) (*Upload, error)

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) Dir added in v0.1.9

func (u *Upload) Dir() bool

Dir reports whether this is a folder.

func (*Upload) Into added in v0.1.9

func (u *Upload) Into(dir string, replace bool) *Upload

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) Name added in v0.1.1

func (u *Upload) Name() string

Name is the file's name; Sent and Size are bytes.

func (*Upload) On added in v0.1.9

func (u *Upload) On(ssh string) *Upload

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

func (u *Upload) Path() string

Path is the stored file's path on the server, once the upload is complete.

func (*Upload) Run added in v0.1.1

func (u *Upload) Run(ctx context.Context) (string, error)

Run sends every remaining chunk and returns the stored file's path.

func (*Upload) Sent added in v0.1.1

func (u *Upload) Sent() int

func (*Upload) Size added in v0.1.1

func (u *Upload) Size() int

func (*Upload) Step added in v0.1.1

func (u *Upload) Step(ctx context.Context) (bool, error)

Step moves the upload on — the first chunk, the next one answered, or the last — and reports whether it is complete.

func (*Upload) Timeout added in v0.1.9

func (u *Upload) Timeout() time.Duration

Timeout is how long the next step may take: the last chunk of a folder has the server unpack it.

Jump to

Keyboard shortcuts

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