worker

package
v13.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 9 Imported by: 12

Documentation

Overview

Package worker implements functions for communicating with subordinate worker processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureWorkerStarted

func EnsureWorkerStarted(state *core.BuildState, worker string, target *core.BuildTarget) error

EnsureWorkerStarted ensures that a worker server is started and has responded saying it's ready.

func ProvideParse

func ProvideParse(state *core.BuildState, worker string, dir string) (string, error)

ProvideParse sends a request to a subprocess to derive pseudo-contents of a BUILD file from a directory (e.g. they may infer it from file contents). If the provider cannot infer anything, they will return an empty string.

func StopAll

func StopAll()

StopAll stops any running worker processes. This should be called before the process terminates to ensure they are all correctly cleaned up.

Types

type Request

type Request struct {
	// The label of the rule to build, i.e. //src/worker:worker
	Rule string `json:"rule"`
	// Labels applies to this rule.
	Labels []string `json:"labels"`
	// The temporary directory to build the target in.
	TempDir string `json:"temp_dir"`
	// List of source files to compile
	Sources []string `json:"srcs"`
	// Compiler options
	Options []string `json:"opts"`
	// True if this message relates to a test.
	Test bool `json:"test"`
}

A Request is the message that's sent to a worker indicating that it should start a build.

type Response

type Response struct {
	// The label of the rule to build, i.e. //src/worker:worker
	// Always corresponds to one that was sent out earlier in a request.
	Rule string `json:"rule"`
	// True if build succeeded
	Success bool `json:"success"`
	// Any messages reported. On failure these should indicate what's gone wrong.
	Messages []string `json:"messages"`
	// The contents of the BUILD file that should be assumed for this directory, if it's a parse request.
	BuildFile string `json:"build_file"`
}

A Response is sent back from the worker on completion.

func BuildRemotely

func BuildRemotely(state *core.BuildState, target *core.BuildTarget, worker string, req *Request) (*Response, error)

BuildRemotely runs a single build request and returns its response.

Jump to

Keyboard shortcuts

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