config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildConfig

type BuildConfig struct {
	// BuildDir is path to directory to cache WebAssembly builds
	BuildDir string `envconfig:"APP_BUILD_DIR" json:"buildDir"`

	// PackagesFile is path to packages JSON index file
	PackagesFile string `envconfig:"APP_PKG_FILE" json:"packagesFile"`

	// CleanupInterval is WebAssembly build artifact cache clean interval
	CleanupInterval time.Duration `envconfig:"APP_CLEAN_INTERVAL" json:"cleanupInterval"`

	// BypassEnvVarsList is allow-list of environment variables
	// that will be passed to Go compiler.
	//
	// Empty value disables environment variable filter.
	BypassEnvVarsList []string `envconfig:"APP_PERMIT_ENV_VARS" json:"bypassEnvVarsList"`
}

type Config

type Config struct {
	HTTP       HTTPConfig       `json:"http"`
	Playground PlaygroundConfig `json:"playground"`
	Build      BuildConfig      `json:"build"`
	Log        LogConfig        `json:"log"`
	Services   ServicesConfig   `json:"services"`
}

func FromEnv

func FromEnv(input *Config) (*Config, error)

FromEnv populates config with values from environment variables.

If passed config is nil - a new config will be returned.

func FromFlagSet

func FromFlagSet(f *flag.FlagSet) *Config

FromFlagSet returns config file which will read values from flags when flag.Parse will be called.

func FromFlags

func FromFlags() *Config

FromFlags return config from parsed process arguments.

type HTTPConfig

type HTTPConfig struct {
	// Addr is HTTP server listen address
	Addr string `envconfig:"APP_HTTP_ADDR" json:"addr"`

	// AssetsDir is directory which contains frontend assets
	AssetsDir string `envconfig:"APP_ASSETS_DIR" json:"assetsDir"`
}

type LogConfig

type LogConfig struct {
	Debug  bool          `envconfig:"APP_DEBUG" json:"debug"`
	Level  zapcore.Level `envconfig:"APP_LOG_LEVEL" json:"level"`
	Format string        `envconfig:"APP_LOG_FORMAT" json:"format"`

	Sentry SentryConfig `json:"sentry"`
}

func (LogConfig) ZapLogger

func (cfg LogConfig) ZapLogger() (*zap.Logger, error)

ZapLogger constructs a new zap.Logger instance from configuration.

type PlaygroundConfig

type PlaygroundConfig struct {
	// PlaygroundURL is Go playground server URL
	PlaygroundURL string `envconfig:"APP_PLAYGROUND_URL" json:"playgroundUrl"`

	// GoTipPlaygroundURL is Go dev playground server URL
	GoTipPlaygroundURL string `envconfig:"APP_GOTIP_URL" json:"goTipPlaygroundUrl"`

	// ConnectTimeout is HTTP request timeout for playground requests
	ConnectTimeout time.Duration `envconfig:"APP_PLAYGROUND_TIMEOUT" json:"connectTimeout"`
}

type SentryConfig

type SentryConfig struct {
	DSN             string        `envconfig:"SENTRY_DSN" json:"dsn"`
	UseBreadcrumbs  bool          `envconfig:"SENTRY_USE_BREADCRUMBS" json:"useBreadcrumbs"`
	BreadcrumbLevel zapcore.Level `envconfig:"SENTRY_BREADCRUMB_LEVEL" json:"breadcrumbLevel"`
}

type ServicesConfig

type ServicesConfig struct {
	// GoogleAnalyticsID is Google Analytics tag ID (optional)
	GoogleAnalyticsID string `envconfig:"APP_GTAG_ID" json:"googleAnalyticsID"`
}

Jump to

Keyboard shortcuts

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