config

package
v0.0.0-...-bc340da Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromJSON5

func LoadFromJSON5(dst interface{}, commonConfigPath, specificConfigPath *string) error

LoadFromJSON5 reads the contents of path and tries to decode the JSON5 there into the provided struct. The passed in struct pointer is expected to have "json" struct tags for all fields. An error will be returned if any non-struct, non-bool field is its zero value *unless* it is tagged with `optional:"true"`.

Types

type CacheType

type CacheType string

CacheType defines the available types for caches.

const (
	RedisCacheType CacheType = "redis"
	LocalCacheType CacheType = "local"
)

type CodeReviewSystem

type CodeReviewSystem struct {
	// ID is how this CRS will be identified via query arguments and ingestion data. This is arbitrary
	// and can be used to distinguish between and internal and public version (e.g. "gerrit-internal")
	ID string `json:"id"`

	// Specifies the APIs/code needed to interact ("gerrit", "github").
	Flavor string `json:"flavor"`

	// A URL with %s where a CL ID should be placed to complete it.
	URLTemplate string `json:"url_template"`

	// URL of the Gerrit instance (if any) where we retrieve CL metadata.
	GerritURL string `json:"gerrit_url" optional:"true"`

	// Filepath to file containing GitHub token (if this instance needs to talk to GitHub).
	GitHubCredPath string `json:"github_cred_path" optional:"true"`

	// User and repo of GitHub project to connect to (if any), e.g. google/skia
	GitHubRepo string `json:"github_repo" optional:"true"`
}

CodeReviewSystem represents the details needed to interact with a CodeReviewSystem (e.g. "gerrit", "github")

type Common

type Common struct {
	// One or more code review systems that we support linking to / commenting on, etc. Used also to
	// identify valid CLs when ingesting data.
	CodeReviewSystems []CodeReviewSystem `json:"code_review_systems"`

	// Google Cloud Storage bucket name.
	GCSBucket string `json:"gcs_bucket"`

	// The primary branch of the git repo to track, e.g. "main".
	GitRepoBranch string `json:"git_repo_branch"`

	// The URL to the git repo that this instance tracks.
	GitRepoURL string `json:"git_repo_url"`

	// GCS path, where the known hashes file should be stored. Format: <bucket>/<path>.
	KnownHashesGCSPath string `json:"known_hashes_gcs_path"`

	// Metrics service address (e.g., ':20000')
	PromPort string `json:"prom_port"`

	// Project ID that houses the pubsub topic.
	PubsubProjectID string `json:"pubsub_project_id"`

	// The port to provide a web handler for /healthz and any other web requests.
	ReadyPort string `json:"ready_port"`

	// URL where this app is hosted.
	SiteURL string `json:"site_url"`

	// The SQL Database type. Eg: cockroachdb, spanner
	SQLDatabaseType DatabaseType `json:"sql_database_type" optional:"true"`

	// SQL username, host and port; typically root@localhost:26234 or root@gold-cockroachdb:26234
	SQLConnection string `json:"sql_connection" optional:"true"`

	// SQL Database name; typically the instance id. e.g. 'flutter', 'skia', etc
	SQLDatabaseName string `json:"sql_database" optional:"true"`

	// TracingProportion overrides the per-service default, which is handy for debugging.
	TracingProportion float64 `json:"tracing_proportion" optional:"true"`

	// Number of recent commits to include in the sliding window of data analysis. Also called the
	// tile size.
	WindowSize int `json:"window_size"`

	// If provided (e.g. ":9002"), a port serving performance-related and other debugging RPCS will
	// be opened up. This RPC will not require authentication.
	DebugPort string `json:"debug_port" optional:"true"`

	// If running locally (not in production).
	Local bool `json:"local"`

	// GroupingParamKeysByCorpus is a map from corpus name to the list of keys that comprise the
	// corpus' grouping.
	GroupingParamKeysByCorpus map[string][]string `json:"grouping_param_keys_by_corpus"`

	// Type of cache to use.
	CacheType CacheType `json:"cache_type"`

	// RedisConfig provides configuration for redis instance to be used for caching.
	RedisConfig redis.RedisConfig `json:"redis_config" optional:"true"`

	// List of corpora to be enabled for caching.
	CachingCorpora []string `json:"cache_corpora" optional:"true"`

	// Caching frequency in minutes.
	CachingFrequencyMinutes int `json:"caching_frequency_minutes" optional:"true"`
}

The Common struct is a set of configuration values that are the same across all instances. Not all instances will use every field in Common, but every field in Common is used in at least two instances (otherwise, it can be deferred to the config specific to its only user). Common should be embedded in all configs specific to a given instance (aka. "Specific Configs"). If a field is defined in both Common and a given specific config, there will be problems, so don't do that.

func (Common) GetCacheClient

func (cfg Common) GetCacheClient(ctx context.Context) (cache.Cache, error)

GetCacheClient returns a cache client based on the configuration.

type DatabaseType

type DatabaseType string

DatabaseType defines the available database types.

const (
	CockroachDB DatabaseType = "cockroachdb"
	Spanner     DatabaseType = "spanner"
)

type Duration

type Duration = config.Duration

Duration allows us to supply a duration as a human readable string.

Directories

Path Synopsis
Test utils provides util functions for gold cmd packages.
Test utils provides util functions for gold cmd packages.

Jump to

Keyboard shortcuts

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