client

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 17 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 implements the engine's Workspace and CommandRunner over the executor FileService and CommandService, against the trusted service or an executor. Semantics: docs/drafts/kubernetes-execution/executor-protocol.md.

Index

Constants

View Source
const (
	DefaultMaxFileBytes    = 256 << 20
	DefaultMaxOutputBytes  = 256 << 20
	DefaultFileCallTimeout = time.Minute
)

Client-side ceilings against a misbehaving executor.

View Source
const ChunkBytes = 3 << 20

ChunkBytes is the most file content sent in one write message.

Variables

View Source
var ErrLimitExceeded = errors.New("executor: response exceeds client limit")

ErrLimitExceeded reports a response over a client limit.

View Source
var ErrOutcomeUnknown = errors.New("executor: command outcome unknown")

ErrOutcomeUnknown reports a command that started but whose end, or the end of every process it started, was not confirmed. Such a command is never retried.

View Source
var ErrStorageTimeout = errors.New(
	"workspace storage did not respond in time; a write may still have completed",
)

ErrStorageTimeout reports a file call that outlived its timeout. The executor may still finish it.

Functions

func Keepalive

func Keepalive(interval, timeout time.Duration) grpc.DialOption

Keepalive fails calls to an executor that stops answering pings.

func NewClient

func NewClient(
	target string,
	creds credentials.TransportCredentials,
	opts ...grpc.DialOption,
) (*grpc.ClientConn, error)

NewClient creates a lazy client with gRPC retries disabled, so no call is sent twice.

Types

type Option

type Option func(*limits)

Option configures a Workspace or Runner.

func WithFileCallTimeout

func WithFileCallTimeout(d time.Duration) Option

WithFileCallTimeout bounds one Workspace call, streams included.

func WithMaxFileBytes

func WithMaxFileBytes(n int) Option

WithMaxFileBytes bounds one file read.

func WithMaxOutputBytes

func WithMaxOutputBytes(n int) Option

WithMaxOutputBytes bounds the output a Runner keeps.

type RequestContextFunc

type RequestContextFunc func(context.Context) (*executorv1.RequestContext, error)

RequestContextFunc returns the request context sent with one call. A nil func sends an empty context, which an executor ignores.

type Runner

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

Runner is a foreground tool.CommandRunner served by a CommandService. It starts each command once; conn must not enable gRPC retries.

func NewRunner

func NewRunner(
	conn grpc.ClientConnInterface,
	root string,
	rc RequestContextFunc,
	opts ...Option,
) *Runner

NewRunner returns a Runner whose commands run in root, the server's workspace root.

func (*Runner) BoundWorkspaceRoot

func (r *Runner) BoundWorkspaceRoot() string

BoundWorkspaceRoot returns the root commands run in.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, command string) (tool.CommandResult, error)

Run implements tool.CommandRunner. Ending ctx cancels the command and still waits, up to cancelGrace, for its result.

type Workspace

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

Workspace is a tool.Workspace served by a FileService. It sends every call once; conn must not enable gRPC retries.

func NewWorkspace

func NewWorkspace(
	conn grpc.ClientConnInterface,
	root string,
	rc RequestContextFunc,
	opts ...Option,
) *Workspace

NewWorkspace returns a Workspace rooted at root, the server's workspace root.

func (*Workspace) AuthorityResourcePath

func (w *Workspace) AuthorityResourcePath(path string) (target, workspace string, err error)

AuthorityResourcePath implements tool.AuthorityResourceResolver.

func (*Workspace) CopyFile

func (w *Workspace) CopyFile(
	ctx context.Context,
	source string,
	destination string,
) (tool.FileVersion, error)

CopyFile implements tool.WorkspaceNamespace.

func (*Workspace) CreateFile

func (w *Workspace) CreateFile(
	ctx context.Context,
	path string,
	data []byte,
) (tool.FileVersion, error)

CreateFile implements tool.Workspace.

func (*Workspace) Glob

func (w *Workspace) Glob(ctx context.Context, pattern string) ([]string, error)

Glob implements tool.Workspace.

func (*Workspace) Grep

func (w *Workspace) Grep(ctx context.Context, pattern, pathGlob string) ([]tool.GrepMatch, error)

Grep implements tool.Workspace.

func (*Workspace) Read

func (w *Workspace) Read(ctx context.Context, path string) ([]byte, error)

Read implements tool.WorkspaceReader.

func (*Workspace) ReadDir

func (w *Workspace) ReadDir(ctx context.Context, path string) ([]tool.FileInfo, error)

ReadDir implements tool.WorkspaceNamespace.

func (*Workspace) ReadVersion

func (w *Workspace) ReadVersion(
	ctx context.Context,
	path string,
) ([]byte, tool.FileVersion, error)

ReadVersion implements tool.Workspace.

func (*Workspace) Remove

func (w *Workspace) Remove(ctx context.Context, path string) error

Remove implements tool.WorkspaceNamespace.

func (*Workspace) Rename

func (w *Workspace) Rename(ctx context.Context, oldPath, newPath string) error

Rename implements tool.WorkspaceNamespace.

func (*Workspace) ReplaceFile

func (w *Workspace) ReplaceFile(
	ctx context.Context,
	path string,
	old tool.FileVersion,
	data []byte,
) (tool.FileVersion, error)

ReplaceFile implements tool.Workspace.

func (*Workspace) Root

func (w *Workspace) Root() string

Root implements tool.WorkspaceReader.

func (*Workspace) Stat

func (w *Workspace) Stat(ctx context.Context, path string) (tool.FileInfo, error)

Stat implements tool.WorkspaceReader.

Jump to

Keyboard shortcuts

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