command

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package command manages commands/toolchains.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWatcherClosed = errors.New("watcher closed")

	// 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(),
		},
	}
)
View Source
var ErrNoUpdate = errors.New("toolchain: configmap no update")

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

Functions

This section is empty.

Types

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

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, force bool) (*cmdpb.ConfigResp, error)

Load loads toolchain config. It will return ErrNoUpdate if there is no seq change when force=false.

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.

Directories

Path Synopsis
Package descriptor provides command descriptor utilities.
Package descriptor provides command descriptor utilities.
posixpath
Package posixpath handles posix-path (Unix style; slash separeted path).
Package posixpath handles posix-path (Unix style; slash separeted path).
winpath
Package winpath handles windows-path (backslash separated path).
Package winpath handles windows-path (backslash separated path).
Package normalizer provides functions to normalize target.
Package normalizer provides functions to normalize target.
Package pathconv provides path converter between client and server.
Package pathconv provides path converter between client and server.

Jump to

Keyboard shortcuts

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