Documentation
¶
Index ¶
- Variables
- func GraphletGetEvaluation[TReference any](ctx context.Context, ...) (model_core.Message[*model_evaluation_pb.Evaluation, TReference], error)
- func NewExecutor(objectDownloader object.Downloader[object.GlobalReference], ...) ...
- type BoundStoreForTesting
- type Computer
- type ComputerFactory
- type ComputerForTesting
- type Environment
- type KeyState
- type KeysReaderForTesting
- type LookupResultReaderForTesting
- type NestedError
- type ObjectManagerForTesting
- type ProtoEvaluationReaderForTesting
- type RecursiveComputer
- func (rc *RecursiveComputer[TReference, TMetadata]) GetEvaluations(ctx context.Context, keyStates []*KeyState[TReference, TMetadata]) (model_core.PatchedMessage[[]*model_evaluation_pb.Evaluations, TMetadata], ...)
- func (rc *RecursiveComputer[TReference, TMetadata]) GetKeyStateKeyMessage(ctx context.Context, ks *KeyState[TReference, TMetadata]) (model_core.TopLevelMessage[*anypb.Any, TReference], error)
- func (rc *RecursiveComputer[TReference, TMetadata]) GetOrCreateKeyState(key model_core.TopLevelMessage[*anypb.Any, TReference]) (*KeyState[TReference, TMetadata], error)
- func (rc *RecursiveComputer[TReference, TMetadata]) GetProgress(ctx context.Context) (model_core.PatchedMessage[*model_evaluation_pb.Progress, TMetadata], error)
- func (rc *RecursiveComputer[TReference, TMetadata]) GracefullyStopUploading()
- func (rc *RecursiveComputer[TReference, TMetadata]) OverrideKeyState(keyReference object.LocalReference, ...) error
- func (rc *RecursiveComputer[TReference, TMetadata]) ProcessNextEvaluatableKey(ctx context.Context, ...) bool
- func (rc *RecursiveComputer[TReference, TMetadata]) ProcessNextUploadableKey(ctx context.Context) (bool, error)
- func (rc *RecursiveComputer[TReference, TMetadata]) WaitForEvaluation(ctx context.Context, ks *KeyState[TReference, TMetadata]) error
- type RecursiveComputerEvaluationQueue
- type RecursiveComputerEvaluationQueuePicker
- type RecursiveComputerEvaluationQueues
- type RecursiveComputerEvaluationQueuesFactory
Constants ¶
This section is empty.
Variables ¶
var ErrMissingDependency = errors.New("missing dependency")
ErrMissingDependency is an error that can be returned by Computer.Compute*Value() to indicate that a value could not be computed due to a dependent value being missing. Retrying the computation after the values of dependencies will allow further progress.
Functions ¶
func GraphletGetEvaluation ¶
func GraphletGetEvaluation[TReference any]( ctx context.Context, reader model_parser.MessageObjectReader[TReference, *model_evaluation_pb.Evaluation], graphlet model_core.Message[*model_evaluation_pb.Graphlet, TReference], ) (model_core.Message[*model_evaluation_pb.Evaluation, TReference], error)
GraphletGetEvaluation is a helper function for obtaining the Evaluation message contained in, or referenced by a Graphlet.
func NewExecutor ¶
func NewExecutor( objectDownloader object.Downloader[object.GlobalReference], computerFactory ComputerFactory[buffered.Reference, *model_core.LeakCheckingReferenceMetadata[buffered.ReferenceMetadata]], evaluationQueuesFactory RecursiveComputerEvaluationQueuesFactory[buffered.Reference, buffered.ReferenceMetadata], parsedObjectPool *model_parser.ParsedObjectPool, dagUploader dag.Uploader[object.InstanceName, object.GlobalReference], tagResolver tag.Resolver[object.Namespace], cacheTagSignaturePrivateKey ed25519.PrivateKey, uploadConcurrency uint32, clock clock.Clock, ) remoteworker.Executor[*model_executewithstorage.Action[object.GlobalReference], model_core.Decodable[object.LocalReference], model_core.Decodable[object.LocalReference]]
NewExecutor creates a remote worker that is capable of executing remote evaluation requests.
Types ¶
type BoundStoreForTesting ¶
type BoundStoreForTesting = model_tag.BoundStore[object.LocalReference]
BoundStoreForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type Computer ¶
type Computer[TReference any, TMetadata model_core.ReferenceMetadata] interface { ComputeMessageValue(ctx context.Context, key model_core.Message[proto.Message, TReference], e Environment[TReference, TMetadata]) (model_core.PatchedMessage[proto.Message, TMetadata], error) ComputeNativeValue(ctx context.Context, key model_core.Message[proto.Message, TReference], e Environment[TReference, TMetadata]) (any, error) IsLookup(typeURL string) bool ReturnsNativeValue(typeURL string) bool }
Computer of values belonging to keys. Keys are always provided in the form of a Protobuf message. The resulting values can either be Protobuf messages, or ones belonging to native Go types.
func NewLeakCheckingComputer ¶
func NewLeakCheckingComputer[TReference any, TMetadata model_core.ReferenceMetadata](base Computer[TReference, *model_core.LeakCheckingReferenceMetadata[TMetadata]]) Computer[TReference, TMetadata]
NewLeakCheckingComputer creates a decorator for Computer that keeps track of all ReferenceMetadata objects that a call to Compute*Value() creates. When any computation causes ReferenceMetadata objects to leak, an error is reported.
type ComputerFactory ¶
type ComputerFactory[TReference any, TMetadata model_core.ReferenceMetadata] interface { NewComputer( namespace object.Namespace, parsedObjectPoolIngester *model_parser.ParsedObjectPoolIngester[TReference], objectExporter model_core.ObjectExporter[TReference, object.LocalReference], ) Computer[TReference, TMetadata] }
ComputerFactory is called into by the executor to obtain an instance of Computer whenever an evaluation request is received.
type ComputerForTesting ¶
type ComputerForTesting Computer[object.LocalReference, model_core.ReferenceMetadata]
ComputerForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type Environment ¶
type Environment[TReference any, TMetadata model_core.ReferenceMetadata] interface { model_core.ObjectManager[TReference, TMetadata] // Methods that implementations of Computer can invoke to get // access to the value of another key. GetMessageValue(key model_core.PatchedMessage[proto.Message, TMetadata]) model_core.Message[proto.Message, TReference] GetNativeValue(key model_core.PatchedMessage[proto.Message, TMetadata]) (any, bool) }
Environment that is provided to Computer.Compute*Value() to obtain access to values of other keys, and to attach Merkle tree nodes to computed keys and values.
type KeyState ¶
type KeyState[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] struct { // contains filtered or unexported fields }
KeyState contains all of the evaluation state of RecursiveComputer for a given key. If evaluation has not yet finished, it stores the list of keys that are currently blocked on it (i.e., its reverse dependencies). When evaluated, it stores the value associated with the key or any error that occurred computing it.
type KeysReaderForTesting ¶
type KeysReaderForTesting = model_parser.MessageObjectReader[object.LocalReference, []*model_evaluation_pb.Keys]
KeysReaderForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type LookupResultReaderForTesting ¶
type LookupResultReaderForTesting = model_parser.MessageObjectReader[object.LocalReference, *model_evaluation_cache_pb.LookupResult]
LookupResultReaderForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type NestedError ¶
type NestedError[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] struct { KeyState *KeyState[TReference, TMetadata] Err error }
NestedError is used to wrap errors that occurred while evaluating a dependency of a given key. The key of the dependency is included, meaning that repeated unwrapping can be used to obtain a stack trace.
func (NestedError[TReference, TMetadata]) Error ¶
func (e NestedError[TReference, TMetadata]) Error() string
type ObjectManagerForTesting ¶
type ObjectManagerForTesting = model_core.ObjectManager[object.LocalReference, model_core.ReferenceMetadata]
ObjectManagerForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type ProtoEvaluationReaderForTesting ¶
type ProtoEvaluationReaderForTesting = model_parser.MessageObjectReader[object.LocalReference, *model_evaluation_pb.Evaluation]
ProtoEvaluationReaderForTesting is used to generate mocks that are used by RecursiveComputer's unit tests.
type RecursiveComputer ¶
type RecursiveComputer[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] struct { // contains filtered or unexported fields }
RecursiveComputer can be used to compute values, taking dependencies between keys into account.
Whenever the computation function requests the value for a key that has not been computed before, the key of the dependency is placed in a queue. Once the values of all previously missing dependencies are available, computation of the original key is restarted. This process repeates itself until all requested keys are exhausted.
func NewRecursiveComputer ¶
func NewRecursiveComputer[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata]( base Computer[TReference, TMetadata], evaluationQueuePicker RecursiveComputerEvaluationQueuePicker[TReference, TMetadata], referenceFormat object.ReferenceFormat, objectManager model_core.ObjectManager[TReference, TMetadata], tagStore model_tag.BoundStore[TReference], actionTagKeyReference object.LocalReference, evaluationReader model_parser.MessageObjectReader[TReference, *model_evaluation_pb.Evaluation], lookupResultReader model_parser.MessageObjectReader[TReference, *model_evaluation_cache_pb.LookupResult], keysReader model_parser.MessageObjectReader[TReference, []*model_evaluation_pb.Keys], cacheDeterministicEncoder model_encoding.DeterministicBinaryEncoder, cacheKeyedEncoder model_encoding.KeyedBinaryEncoder, clock clock.Clock, ) *RecursiveComputer[TReference, TMetadata]
NewRecursiveComputer creates a new RecursiveComputer that is in the initial state (i.e., having no queued or evaluated keys).
func (*RecursiveComputer[TReference, TMetadata]) GetEvaluations ¶
func (rc *RecursiveComputer[TReference, TMetadata]) GetEvaluations(ctx context.Context, keyStates []*KeyState[TReference, TMetadata]) (model_core.PatchedMessage[[]*model_evaluation_pb.Evaluations, TMetadata], error)
GetEvaluations returns a B-tree of evaluations, including graphlets for all provided KeyStates, including all of their transitive dependencies.
func (*RecursiveComputer[TReference, TMetadata]) GetKeyStateKeyMessage ¶
func (rc *RecursiveComputer[TReference, TMetadata]) GetKeyStateKeyMessage(ctx context.Context, ks *KeyState[TReference, TMetadata]) (model_core.TopLevelMessage[*anypb.Any, TReference], error)
GetKeyStateKeyMessage returns the message of the key that is associated with the provided KeyState. This can, for example, be used to generate proper stack traces using the KeyState instances referenced by NestedError.
func (*RecursiveComputer[TReference, TMetadata]) GetOrCreateKeyState ¶
func (rc *RecursiveComputer[TReference, TMetadata]) GetOrCreateKeyState(key model_core.TopLevelMessage[*anypb.Any, TReference]) (*KeyState[TReference, TMetadata], error)
GetOrCreateKeyState looks up the key state for a given key. If the key state does not yet exist, it is created.
func (*RecursiveComputer[TReference, TMetadata]) GetProgress ¶
func (rc *RecursiveComputer[TReference, TMetadata]) GetProgress(ctx context.Context) (model_core.PatchedMessage[*model_evaluation_pb.Progress, TMetadata], error)
GetProgress returns a Protobuf message containing counters on the number of keys that have been evaluated, are currently queued, or are currently blocked on other keys. In addition to that, it returns the list of keys that are currently being evaluated. This message can be returned to clients to display progress.
func (*RecursiveComputer[TReference, TMetadata]) GracefullyStopUploading ¶
func (rc *RecursiveComputer[TReference, TMetadata]) GracefullyStopUploading()
GracefullyStopUploading can be used to ensure that calls to ProcessNextUploadableKey() no longer block, but immediately return if no keys need to be uploaded.
func (*RecursiveComputer[TReference, TMetadata]) OverrideKeyState ¶
func (rc *RecursiveComputer[TReference, TMetadata]) OverrideKeyState(keyReference object.LocalReference, value model_core.TopLevelMessage[*anypb.Any, TReference]) error
OverrideKeyState overrides the value for a given key. This prevents the key from getting evaluated, and causes evaluation of keys that depend on it to receive the injected value.
func (*RecursiveComputer[TReference, TMetadata]) ProcessNextEvaluatableKey ¶
func (rc *RecursiveComputer[TReference, TMetadata]) ProcessNextEvaluatableKey(ctx context.Context, rceq *RecursiveComputerEvaluationQueue[TReference, TMetadata]) bool
ProcessNextEvaluatableKey blocks until one or more keys are queued for evaluation. After that it will attempt to evaluate it.
func (*RecursiveComputer[TReference, TMetadata]) ProcessNextUploadableKey ¶
func (rc *RecursiveComputer[TReference, TMetadata]) ProcessNextUploadableKey(ctx context.Context) (bool, error)
ProcessNextUploadableKey processes one of the recently evaluated keys and uploads its results into storage, so that subsequent builds can reuse cached results.
func (*RecursiveComputer[TReference, TMetadata]) WaitForEvaluation ¶
func (rc *RecursiveComputer[TReference, TMetadata]) WaitForEvaluation(ctx context.Context, ks *KeyState[TReference, TMetadata]) error
WaitForEvaluation blocks until a given key has evaluated. Once evaluated, any errors evaluating the key are returned.
type RecursiveComputerEvaluationQueue ¶
type RecursiveComputerEvaluationQueue[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] struct { // contains filtered or unexported fields }
RecursiveComputerEvaluationQueue represents a queue of evaluation keys that are currently not blocked and are ready to be evaluated.
Instances of RecursiveComputer can make use of multiple evaluation queues. This can be used to enforce that different types of keys are evaluated with different amounts of concurrency. For example, keys that are CPU intensive to evaluate can be executed with a concurrency proportional to the number of locally available CPU cores, while keys that perform long-running network requests can use a higher amount of concurrency.
func NewRecursiveComputerEvaluationQueue ¶
func NewRecursiveComputerEvaluationQueue[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata]() *RecursiveComputerEvaluationQueue[TReference, TMetadata]
NewRecursiveComputerEvaluationQueue creates a new RecursiveComputerEvaluationQueue that does not have any queues keys.
type RecursiveComputerEvaluationQueuePicker ¶
type RecursiveComputerEvaluationQueuePicker[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] interface { PickQueue(typeURL string) *RecursiveComputerEvaluationQueue[TReference, TMetadata] }
RecursiveComputerEvaluationQueuePicker is used by RecursiveComputer to pick a RecursiveComputerEvaluationQueue to which a given key should be assigned.
type RecursiveComputerEvaluationQueues ¶
type RecursiveComputerEvaluationQueues[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] interface { RecursiveComputerEvaluationQueuePicker[TReference, TMetadata] ProcessAllEvaluatableKeys(group program.Group, computer *RecursiveComputer[TReference, TMetadata]) }
RecursiveComputerEvaluationQueues represents a set of queues that RecursiveComputer may use to schedule the evaluation of keys.
Simple implementations may place all keys in a single queue, but this has the disadvantage that all work is limited by the same concurrency limit. This may be sufficient if all work is CPU intensive, but may lead to low utilization if some work calls into remote services and may block for large amounts of time.
type RecursiveComputerEvaluationQueuesFactory ¶
type RecursiveComputerEvaluationQueuesFactory[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata] interface { NewQueues() RecursiveComputerEvaluationQueues[TReference, TMetadata] }
RecursiveComputerEvaluationQueuesFactory is invoked by Executor to create the queues that are necessary to schedule the evaluation of keys.
func NewSimpleRecursiveComputerEvaluationQueuesFactory ¶
func NewSimpleRecursiveComputerEvaluationQueuesFactory[TReference object.BasicReference, TMetadata model_core.ReferenceMetadata](concurrency uint32) RecursiveComputerEvaluationQueuesFactory[TReference, TMetadata]
NewSimpleRecursiveComputerEvaluationQueuesFactory creates a RecursiveComputerEvaluationQueuesFactory that always returns RecursiveComputerEvaluationQueues instances backed by a single queue.
This implementation may be sufficient for testing, or can be used as a base type for more advanced implementations that create multiple queues.