config

package
v0.0.0-...-642d756 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package config provides the definition of the configuration for the frontend.

Index

Constants

View Source
const (
	// BypassQuotaAuthHeader is the header key used by the frontend server to know
	// that a request can bypass the quota server.
	BypassQuotaAuthHeader = "X-Go-Discovery-Auth-Bypass-Quota"

	// BypassCacheAuthHeader is the header key used by the frontend server to
	// know that a request can bypass cache.
	BypassCacheAuthHeader = "X-Go-Discovery-Auth-Bypass-Cache"

	// BypassErrorReportingHeader is the header key used by the ErrorReporting middleware
	// to avoid calling the errorreporting service.
	BypassErrorReportingHeader = "X-Go-Discovery-Bypass-Error-Reporting"

	// AllowDebugHeader is the header key used by the frontend server that allows
	// serving debug pages.
	AllowDebugHeader = "X-Go-Discovery-Debug"
)
View Source
const AppVersionFormat = "20060102t150405"

AppVersionFormat is the expected format of the app version timestamp.

View Source
const SourceTimeout = 1 * time.Minute

SourceTimeout is the value of the timeout for source.Client, which is used to fetch source code from third party URLs.

View Source
const StatementTimeout = 30 * time.Minute

StatementTimeout is the value of the Postgres statement_timeout parameter. Statements that run longer than this are terminated. 10 minutes is the App Engine standard request timeout, but we set this longer for the worker.

View Source
const TaskIDChangeIntervalFrontend = 30 * time.Minute

TaskIDChangeIntervalFrontend is the time period during which a given module version can be re-enqueued to frontend tasks.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// AuthValues is the set of values that could be set on the AuthHeader, in
	// order to bypass checks by the cache.
	AuthValues []string

	// Discovery environment variables
	ProxyURL, IndexURL string

	// Ports used for hosting. 'DebugPort' is used for serving HTTP debug pages.
	Port, DebugPort string

	// AppEngine identifiers
	ProjectID, ServiceID, VersionID, ZoneID, InstanceID, LocationID string

	// ServiceAccount is the email of the service account that this process
	// is running as when on GCP.
	ServiceAccount string

	// QueueURL is the URL that the Cloud Tasks queue should send requests to.
	// It should be used when the worker is not on AppEngine.
	QueueURL string

	// QueueAudience is used to allow the Cloud Tasks queue to authorize itself
	// to the worker. It should be the OAuth 2.0 client ID associated with the
	// IAP that is gating access to the worker.
	QueueAudience string

	// GoogleTagManagerID is the ID used for GoogleTagManager. It has the
	// structure GTM-XXXX.
	GoogleTagManagerID string

	// MonitoredResource represents the resource that is running the current binary.
	// It might be a Google AppEngine app, a Cloud Run service, or a Kubernetes pod.
	// See https://cloud.google.com/monitoring/api/resources for more
	// details:
	// "An object representing a resource that can be used for monitoring, logging,
	// billing, or other purposes. Examples include virtual machine instances,
	// databases, and storage devices such as disks.""
	MonitoredResource *MonitoredResource

	// FallbackVersionLabel is used as the VersionLabel when not hosting on
	// AppEngine.
	FallbackVersionLabel string

	DBSecret, DBUser, DBHost, DBPort, DBName, DBSSL string
	DBSecondaryHost                                 string // DB host to use if first one is down
	DBPassword                                      string `json:"-" yaml:"-"`

	// Configuration for redis page cache.
	RedisCacheHost, RedisBetaCacheHost, RedisCachePort string

	// UseProfiler specifies whether to enable Stackdriver Profiler.
	UseProfiler bool

	Quota QuotaSettings

	// Minimum log level below which no logs will be printed.
	// Possible values are [debug, info, error, fatal].
	// In case of invalid/empty value, all logs will be printed.
	LogLevel string

	// DynamicConfigLocation is the location (either a file or gs://bucket/object) for
	// dynamic configuration.
	DynamicConfigLocation string

	// DynamicExcludeLocation is the location (either a file or gs://bucket/object) for
	// dynamic exclusion file.
	DynamicExcludeLocation string

	// ServeStats determines whether the server has an endpoint that serves statistics for
	// benchmarking or other purposes.
	ServeStats bool

	// DisableErrorReporting disables sending errors to the GCP ErrorReporting system.
	DisableErrorReporting bool

	// VulnDB is the URL of the Go vulnerability DB.
	VulnDB string
}

Config holds shared configuration values used in instantiating our server components.

func (*Config) AppVersionLabel

func (c *Config) AppVersionLabel() string

AppVersionLabel returns the version label for the current instance. This is the AppVersionID available, otherwise a string constructed using the timestamp of process start.

func (*Config) Application

func (c *Config) Application() string

Application returns the name of the running application: "worker", "frontend", etc.

func (*Config) DBConnInfo

func (c *Config) DBConnInfo() string

DBConnInfo returns a PostgreSQL connection string constructed from environment variables, using the primary database host.

func (*Config) DBSecondaryConnInfo

func (c *Config) DBSecondaryConnInfo() string

DBSecondaryConnInfo returns a PostgreSQL connection string constructed from environment variables, using the backup database host. It returns the empty string if no backup is configured.

func (*Config) DebugAddr

func (c *Config) DebugAddr(dflt string) string

DebugAddr returns the network address on which to serve debugging information.

func (*Config) DeploymentEnvironment

func (c *Config) DeploymentEnvironment() string

DeploymentEnvironment returns the deployment environment this process is in: usually one of "local", "exp", "dev", "staging" or "prod".

func (*Config) Dump

func (c *Config) Dump(w io.Writer) error

Dump outputs the current config information to the given Writer.

func (*Config) HostAddr

func (c *Config) HostAddr(dflt string) string

HostAddr returns the network on which to serve the primary HTTP service.

type MonitoredResource

type MonitoredResource struct {
	Type string `yaml:"type,omitempty"`

	Labels map[string]string `yaml:"labels,omitempty"`
}

MonitoredResource represents the resource that is running the current binary. It might be a Google AppEngine app, a Cloud Run service, or a Kubernetes pod. See https://cloud.google.com/monitoring/api/resources for more details: "An object representing a resource that can be used for monitoring, logging, billing, or other purposes. Examples include virtual machine instances, databases, and storage devices such as disks."

type QuotaSettings

type QuotaSettings struct {
	Enable     bool `yaml:"Enable"`
	QPS        int  `yaml:"QPS"`        // allowed queries per second, per IP block
	Burst      int  `yaml:"Burst"`      // maximum requests per second, per block; the size of the token bucket
	MaxEntries int  `yaml:"MaxEntries"` // maximum number of entries to keep track of
	// Record data about blocking, but do not actually block.
	// This is a *bool, so we can distinguish "not present" from "false" in an override
	RecordOnly *bool `yaml:"RecordOnly"`
	// AuthValues is the set of values that could be set on the AuthHeader, in
	// order to bypass checks by the quota server.
	AuthValues []string `yaml:"AuthValues"`
	HMACKey    []byte   `json:"-" yaml:"-"` // key for obfuscating IPs
}

QuotaSettings is config for internal/middleware/quota.go

Directories

Path Synopsis
Package dynconfig supports dynamic configuration for pkgsite services.
Package dynconfig supports dynamic configuration for pkgsite services.
Package serverconfig resolves shared configuration for Go Discovery services.
Package serverconfig resolves shared configuration for Go Discovery services.

Jump to

Keyboard shortcuts

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