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
- Variables
- func Keepalive(interval, timeout time.Duration) grpc.DialOption
- func NewClient(target string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- type Option
- type RequestContextFunc
- type Runner
- type Workspace
- func (w *Workspace) AuthorityResourcePath(path string) (target, workspace string, err error)
- func (w *Workspace) CopyFile(ctx context.Context, source string, destination string) (tool.FileVersion, error)
- func (w *Workspace) CreateFile(ctx context.Context, path string, data []byte) (tool.FileVersion, error)
- func (w *Workspace) Glob(ctx context.Context, pattern string) ([]string, error)
- func (w *Workspace) Grep(ctx context.Context, pattern, pathGlob string) ([]tool.GrepMatch, error)
- func (w *Workspace) Read(ctx context.Context, path string) ([]byte, error)
- func (w *Workspace) ReadDir(ctx context.Context, path string) ([]tool.FileInfo, error)
- func (w *Workspace) ReadVersion(ctx context.Context, path string) ([]byte, tool.FileVersion, error)
- func (w *Workspace) Remove(ctx context.Context, path string) error
- func (w *Workspace) Rename(ctx context.Context, oldPath, newPath string) error
- func (w *Workspace) ReplaceFile(ctx context.Context, path string, old tool.FileVersion, data []byte) (tool.FileVersion, error)
- func (w *Workspace) Root() string
- func (w *Workspace) Stat(ctx context.Context, path string) (tool.FileInfo, error)
Constants ¶
const ( DefaultMaxFileBytes = 256 << 20 DefaultMaxOutputBytes = 256 << 20 DefaultFileCallTimeout = time.Minute )
Client-side ceilings against a misbehaving executor.
const ChunkBytes = 3 << 20
ChunkBytes is the most file content sent in one write message.
Variables ¶
var ErrLimitExceeded = errors.New("executor: response exceeds client limit")
ErrLimitExceeded reports a response over a client limit.
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.
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 ¶
WithFileCallTimeout bounds one Workspace call, streams included.
func WithMaxOutputBytes ¶
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 ¶
BoundWorkspaceRoot returns the root commands run in.
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 ¶
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) ReadVersion ¶
func (w *Workspace) ReadVersion( ctx context.Context, path string, ) ([]byte, tool.FileVersion, error)
ReadVersion implements tool.Workspace.
func (*Workspace) ReplaceFile ¶
func (w *Workspace) ReplaceFile( ctx context.Context, path string, old tool.FileVersion, data []byte, ) (tool.FileVersion, error)
ReplaceFile implements tool.Workspace.