remoteworker

package
v0.0.0-...-1b293c9 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LaunchWorkerThread

func LaunchWorkerThread(group program.Group, run func(ctx context.Context) (bool, error), workerName string)

LaunchWorkerThread launches a single routine that uses a build client to repeatedly synchronizes against the scheduler, requesting a task to execute.

func ParsePlatformPrivateKeys

func ParsePlatformPrivateKeys(privateKeys []string) ([]*ecdh.PrivateKey, error)

ParsePlatformPrivateKeys parses a set of ECDH private keys specified in a worker's configuration file, so that they can be provided to NewClient().

Types

type Client

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

Client for the Remote Worker protocol. It can send synchronization requests to a scheduler, informing it of the current state of the worker, while also obtaining requests for executing actions.

func NewClient

func NewClient(
	scheduler remoteworker_pb.OperationQueueClient,
	executor Executor[[]byte, []byte, []byte],
	clock clock.Clock,
	randomNumberGenerator random.ThreadSafeGenerator,
	unsortedPrivateKeys []*ecdh.PrivateKey,
	clientCertificateVerifier *bb_x509.ClientCertificateVerifier,
	workerID map[string]string,
	sizeClass uint32,
	isLargestSizeClass bool,
) (*Client, error)

NewClient creates a new Client instance that is set to the initial state (i.e., being idle).

func (*Client) Run

func (c *Client) Run(ctx context.Context) (bool, error)

Run an iteration of the Remote Worker client, by performing a single synchronization against the scheduler.

type Executor

type Executor[TAction, TEvent, TResult any] interface {
	CheckReadiness(ctx context.Context) error
	Execute(ctx context.Context, action TAction, executionTimeout time.Duration, executionEvents chan<- TEvent) (TResult, time.Duration, remoteworker_pb.CurrentState_Completed_Result, error)
}

Executor is responsible for processing an incoming action, executing it, and returning its results. The remote worker client will assume that all payloads are byte slices, but decorators can be written to transmit things like Protobuf messages.

Implementations of Executor.Execute() should only return an error if there are no other mechanisms available to propagate errors to the the caller. The reason being that any error returned directly is sent back to the client in plain text, as opposed to getting encrypted.

func NewProtoExecutor

func NewProtoExecutor[
	TAction any,
	TEvent proto.Message,
	TResult proto.Message,
	TActionPtr interface {
		*TAction
		proto.Message
	},
](
	base Executor[TActionPtr, TEvent, TResult],
) Executor[[]byte, []byte, []byte]

NewProtoExecutor creates a decorator for Executor that assumes that all payloads of an action (i.e., its action, execution event and completion event message) are Protobuf messages. It marshals and unmarshals all these messages, so that they can be sent and transmitted in binary form.

Jump to

Keyboard shortcuts

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