Back to godoc.org

Package command

v0.0.15
Latest Go to latest

The latest major version is .

Published: Jul 31, 2020 | License: BSD-3-Clause | Module: go.chromium.org/goma/server

Overview

Package command manages commands/toolchains.

Index

Variables

var (

	// DefaultViews are the default views provided by this package.
	// You need to register the view for data to actually be collected.
	DefaultViews = []*view.View{
		{
			Description: "configmap pubsub error",
			Measure:     pubsubErrors,
			Aggregation: view.Count(),
		},
	}
)
var ErrNoUpdate = errors.New("toolchain: configmap no update")

ErrNoUpdate indicates no update in configmap, returned by ConfigMapLoader.Load.

type ConfigLoader

type ConfigLoader struct {
	StorageClient  stiface.Client
	EnableParallel bool
	// contains filtered or unexported fields
}

ConfigLoader loads toolchain_config from cloud storage.

func (*ConfigLoader) Load

func (c *ConfigLoader) Load(ctx context.Context, uri string, rc *cmdpb.RuntimeConfig) ([]*cmdpb.Config, error)

Load loads toolchain config from <uri>. It sets rc.ServiceAddr as target addr.

type ConfigMap

type ConfigMap interface {
	// Watcher returns config map watcher.
	Watcher(ctx context.Context) ConfigMapWatcher

	// Seqs returns a map of config name to sequence.
	Seqs(ctx context.Context) (map[string]string, error)

	// Bucket returns toolchain-config bucket.
	Bucket(ctx context.Context) (string, error)

	// RuntimeConfigs returns a map of RuntimeConfigs.
	RuntimeConfigs(ctx context.Context) (map[string]*cmdpb.RuntimeConfig, error)
}

ConfigMap is an interface to access toolchain config map.

type ConfigMapBucket

type ConfigMapBucket struct {
	// URI of config data.
	// gs://<bucket>/
	// e.g. gs://$project-toolchain-config/
	URI string

	ConfigMap     *cmdpb.ConfigMap
	ConfigMapFile string

	PubsubClient *pubsub.Client

	// StorageClient is an interface for accessing Cloud Storage. It can
	// be a Cloud Storage client or a fake for testing.
	StorageClient stiface.Client

	// SubscriberID should be unique per each server instance
	// to get notification in every server instance.
	SubscriberID string

	// Remoteexec API address, if RBE API is used.
	// Otherwise, use service_addr in RuntimeConfig proto.
	RemoteexecAddr string
}

ConfigMapBucket access config on cloud storage bucket.

<bucket> is <project>-toolchain-config. in the <bucket>

<runtime>/
         seq: text, sequence number.
         <prebuilt-item>/descriptors/<descriptorHash>: proto CmdDescriptor

Watcher watches */seq files via default notification topic on the bucket. Seqs and RuntimeConfigs will read ConfigMapFile everytime.

func (ConfigMapBucket) Bucket

func (c ConfigMapBucket) Bucket(ctx context.Context) (string, error)

func (ConfigMapBucket) RuntimeConfigs

func (c ConfigMapBucket) RuntimeConfigs(ctx context.Context) (map[string]*cmdpb.RuntimeConfig, error)

func (ConfigMapBucket) Seqs

func (c ConfigMapBucket) Seqs(ctx context.Context) (map[string]string, error)

func (ConfigMapBucket) Watcher

func (c ConfigMapBucket) Watcher(ctx context.Context) ConfigMapWatcher

type ConfigMapLoader

type ConfigMapLoader struct {
	ConfigMap    ConfigMap
	ConfigLoader ConfigLoader
	ConfigStore  ConfigStore
}

ConfigMapLoader loads toolchain_config config map.

ConfigMap provides Watcher, Seqs, Bucket and RuntimeConfigs.

if seq is updated from last load, it will load CmdDescriptor from <bucket>/<runtime>/<prebuilt_item>/descriptors/<descriptorHash>.

func (*ConfigMapLoader) Load

func (c *ConfigMapLoader) Load(ctx context.Context) (*cmdpb.ConfigResp, error)

Load loads toolchain config. It will return ErrNoUpdate if there is no seq change.

type ConfigMapWatcher

type ConfigMapWatcher interface {
	// Next waits for some updates in config map.
	Next(ctx context.Context) error

	// Close closes the watcher.
	Close() error
}

ConfigMapWatcher is an interface to watch config map.

type ConfigStore

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

ConfigStore holds latest config.

func (*ConfigStore) ConfigResp

func (c *ConfigStore) ConfigResp() *cmdpb.ConfigResp

ConfigResp returns current ConfigResp.

func (*ConfigStore) Delete

func (c *ConfigStore) Delete(name string)

Delete deletes name's config.

func (*ConfigStore) List

func (c *ConfigStore) List() []string

List returns a list of config names.

func (*ConfigStore) Seq

func (c *ConfigStore) Seq(name string) string

Seq returns seq of name's config.

func (*ConfigStore) Set

func (c *ConfigStore) Set(name, seq string, confs []*cmdpb.Config)

Set sets name's confs with seq.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier