Documentation ¶
Index ¶
- type Key
- type KeyExtractor
- func NewActionAndCommandKeyExtractor(contentAddressableStorage blobstore.BlobAccess, maximumMessageSizeBytes int) KeyExtractor
- func NewKeyExtractorFromConfiguration(configuration *pb.PlatformKeyExtractorConfiguration, ...) (KeyExtractor, error)
- func NewStaticKeyExtractor(platform *remoteexecution.Platform) KeyExtractor
- type Trie
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key of a platform on which execution may take place. In addition to the REv2 platform properties, the key contains the instance name value. Each instance name may be associated with its own kinds of workers.
func MustNewKey ¶
func MustNewKey(instanceNamePrefix string, platform *remoteexecution.Platform) Key
MustNewKey is identical to NewKey, except that it panics upon failure.
func NewKey ¶
func NewKey(instanceNamePrefix digest.InstanceName, platform *remoteexecution.Platform) (Key, error)
NewKey creates a new Key of a platform, given an instance name and REv2 platform properties message.
func (Key) GetInstanceNamePrefix ¶
func (k Key) GetInstanceNamePrefix() digest.InstanceName
GetInstanceNamePrefix returns the instance name that was provided when the Key was created.
func (Key) GetPlatformQueueName ¶
func (k Key) GetPlatformQueueName() *buildqueuestate.PlatformQueueName
GetPlatformQueueName reobtains the instance name prefix and Platform message that was used to construct the Key. As this is only used infrequently, we don't bother keeping the unmarshalled Platform message around to preserve memory usage.
func (Key) GetPlatformString ¶
GetPlatformString returns the Platform message that was used to construct the Key in JSON form. This string is generated deterministically, so it is safe to use for stable comparisons, map keys and Prometheus metric label values.
type KeyExtractor ¶
type KeyExtractor interface {
ExtractKey(ctx context.Context, digestFunction digest.Function, action *remoteexecution.Action) (Key, error)
}
KeyExtractor is responsible for creating a platform key for an incoming action execution request, which InMemoryBuildQueue will use to determine in which queue an operation is placed.
This interface is used to switch between REv2.1 semantics (reading platform properties from the Command message), REv2.2 semantics (reading platform properties from the Action message), or to let the scheduler rewrite/override platform properties provided by the client.
var ActionKeyExtractor KeyExtractor = actionKeyExtractor{}
ActionKeyExtractor is capable of extracting a platform key from an REv2 Action message.
Because it does not fall back to reading platform properties from the Command message, it is only capable of processing requests sent by a client that implements REv2.2 or newer.
func NewActionAndCommandKeyExtractor ¶
func NewActionAndCommandKeyExtractor(contentAddressableStorage blobstore.BlobAccess, maximumMessageSizeBytes int) KeyExtractor
NewActionAndCommandKeyExtractor creates a new KeyExtractor is capable of extracting a platform key from an REv2 Action message. If no platform properties are specified in the Action, it falls back to reading them from the Command message.
This platform key extractor needs to be used if requests from clients that implement REv2.1 or older need to be processed, as platform properties were only added to the Action message in REv2.2.
func NewKeyExtractorFromConfiguration ¶
func NewKeyExtractorFromConfiguration(configuration *pb.PlatformKeyExtractorConfiguration, contentAddressableStorage blobstore.BlobAccess, maximumMessageSizeBytes int) (KeyExtractor, error)
NewKeyExtractorFromConfiguration creates a new KeyExtractor based on options specified in a configuration file.
func NewStaticKeyExtractor ¶
func NewStaticKeyExtractor(platform *remoteexecution.Platform) KeyExtractor
NewStaticKeyExtractor creates a KeyExtractor that ignores the platform properties provided as part of the action and returns a constant value. This implementation is useful in combination with DemultiplexingActionRouter, in case rewriting of platform properties needs to be performed.
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is a prefix tree for instance names and platform properties. It can be used by implementations of BuildQueue to match instance names and platform properties provides as part of execution requests against individual platform queues.
For every key stored in the trie, an integer value is tracked. This can, for example, be used by the caller to look up a corresponding value in a contiguous list.
func NewTrie ¶
func NewTrie() *Trie
NewTrie creates a new Trie that is initialized with no elements.
func (*Trie) ContainsExact ¶
ContainsExact returns whether the trie contains a key that is exactly the same as the one provided.
func (*Trie) GetExact ¶
GetExact returns the value associated with the key. If none of the keys provided to Set() are exactly the same as the key provided to GetExact(), this function returns -1.
func (*Trie) GetLongestPrefix ¶
GetLongestPrefix returns the value associated with the longest matching instance name prefix, having the same platform properties. If none of the keys provided to Set() have an instance name that is a prefix, or have the same platform properties as that of the key provided to GetLongestPrefix(), this function returns -1.