config

package
v0.0.0-...-5abe684 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostprocessAdminConfig

func PostprocessAdminConfig(config *AdminConfig) error

PostprocessAdminConfig cleanups user supplied config object.

func PostprocessChannelsConfig

func PostprocessChannelsConfig(list *ChannelsConfig) error

PostprocessChannelsConfig fixes/validates config

func PostprocessHTTPServerConfig

func PostprocessHTTPServerConfig(config *HTTPServerConfig, overrides Overrides) error

PostprocessHTTPServerConfig cleanups user supplied config object.

func PostprocessSentryConfig

func PostprocessSentryConfig(config *SentryConfig, overrides Overrides) error

PostprocessSentryConfig fixup given configurations

func PostprocessStorageConfig

func PostprocessStorageConfig(config *StoragesConfig) error

PostprocessStorageConfig fixup given configurations

func PostprocessTelemetryConfig

func PostprocessTelemetryConfig(config *TelemetryConfig) error

PostprocessTelemetryConfig fixes/validates config

Types

type AdminAuthConfig

type AdminAuthConfig struct {
	Networks     []domain.CIDR `json:"networks"`
	BearerTokens []string      `json:"bearer"`
}

AdminAuthConfig represents auth settings of admin endpoints

type AdminConfig

type AdminConfig struct {
	Auth AdminAuthConfig `json:"auth"`
}

AdminConfig represents administration feature settings

type BuildInfo

type BuildInfo struct {
	BuildVersion string       `json:"buildVersion"`
	BuildAt      *domain.Time `json:"buildAt"`
}

BuildInfo represents compile time metadata.

type ChannelConfig

type ChannelConfig struct {
	Regex  *domain.Regex    `json:"regex"`
	Expire *domain.Duration `json:"expire"`

	Webhooks []OutgoingWebhookConfig `json:"webhooks"`
	Jwt      *JwtValidationConfig    `json:"jwt"`
}

ChannelConfig represents channel configuration

type ChannelsConfig

type ChannelsConfig []ChannelConfig

ChannelsConfig is list of configured channels

type HTTPServerConfig

type HTTPServerConfig struct {
	Port                        int               `json:"port" validate:"min=0,max=65535"`
	Listen                      string            `json:"listen"`
	PathPrefix                  string            `json:"pathPrefix"`
	RealIPHeader                string            `json:"realIpHeader"`
	TrustedProxyRanges          []domain.CIDR     `json:"trustedProxyRanges"`
	DiscloseAuthRejectionDetail bool              `json:"discloseAuthRejectionDetail"`
	DefaultHeaders              map[string]string `json:"defaultHeaders"`

	IdleTimeout             domain.Duration `json:"idleTimeout"`
	ReadTimeout             domain.Duration `json:"readTimeout"`
	WriteTimeout            domain.Duration `json:"writeTimeout"`
	LongPollingMaxTimeout   domain.Duration `json:"longPollingMaxTimeout"`
	GracefulShutdownTimeout domain.Duration `json:"gracefulShutdownTimeout"`
}

HTTPServerConfig represents HTTP webserver settings

type JwtValidationConfig

type JwtValidationConfig struct {
	Iss  []domain.JwtIss            `json:"iss"`
	Aud  []domain.JwtAud            `json:"aud"`
	Keys map[domain.JwtAlg][]string `json:"keys"`

	Claims map[string]domain.TemplateStrings `json:"claims"`

	ClockSkewLeeway *domain.Duration `json:"clockSkewLeeway"`
}

JwtValidationConfig is JWT configuration of a channel

type LoggingConfig

type LoggingConfig struct {
	Category   map[string]string `json:"category"`
	Attributes map[string]string `json:"attributes"`
}

LoggingConfig represents logger and logging settings

type OnmemoryStorageConfig

type OnmemoryStorageConfig struct {
	DisablePubSub bool `json:"__disablePubSub"`
	DisableJwt    bool `json:"__disableJwt"`

	RunGCOnShutdown bool `json:"__runGcOnShutdown"`
}

OnmemoryStorageConfig is definition of "storage.onmemory" configuration

type OpenTelemetryConfig

type OpenTelemetryConfig struct {
	Tracing *OpenTelemetryTracingConfig `json:"tracing"`

	Exporters OpenTelemetryExportersConfig `json:"exporters"`
}

OpenTelemetryConfig is to setup OpenTelemetry

type OpenTelemetryExporterGCPConfig

type OpenTelemetryExporterGCPConfig struct {
	EnableTrace bool   `json:"enableTrace"`
	ProjectID   string `json:"projectID"`
}

OpenTelemetryExporterGCPConfig configure GCP expoter

type OpenTelemetryExporterStdoutConfig

type OpenTelemetryExporterStdoutConfig struct {
	Enable    bool      `json:"enable"`
	Quantiles []float64 `json:"quantiles"`
}

OpenTelemetryExporterStdoutConfig configure stdout exporter

type OpenTelemetryExportersConfig

type OpenTelemetryExportersConfig struct {
	Stdout OpenTelemetryExporterStdoutConfig `json:"stdout"`
	GCP    OpenTelemetryExporterGCPConfig    `json:"gcp"`
}

OpenTelemetryExportersConfig configure exporters

type OpenTelemetryTracingBatchConfig

type OpenTelemetryTracingBatchConfig struct {
	MaxQueueSize *int             `json:"maxQueueSize"`
	Timeout      *domain.Duration `json:"timeout"`
	BatchSize    *int             `json:"batchSize"`
}

OpenTelemetryTracingBatchConfig is to configure batch transmission

type OpenTelemetryTracingConfig

type OpenTelemetryTracingConfig struct {
	Enable   bool    `json:"enable"`
	Sampling float64 `json:"sampling"`

	Batch OpenTelemetryTracingBatchConfig `json:"batch"`

	Attributes map[string]interface{} `json:"attributes"`
}

OpenTelemetryTracingConfig is to setup OpenTelemetry tracing

type OutgoingWebhookConfig

type OutgoingWebhookConfig struct {
	Method     string                           `json:"method"`
	URL        *domain.TemplateString           `json:"url"`
	Timeout    *domain.Duration                 `json:"timeout"`
	Connection OutgoingWebhookConnectionConfig  `json:"connection"`
	Retry      OutgoingWebhookRetryConfig       `json:"retry"`
	Headers    map[string]domain.TemplateString `json:"headers"`

	MaxRedirects *int `json:"maxRedirects"`
}

OutgoingWebhookConfig is webhook configuration of a channel

type OutgoingWebhookConnectionConfig

type OutgoingWebhookConnectionConfig struct {
	Max         *int             `json:"max"`
	MaxIdleTime *domain.Duration `json:"maxIdleTime"`
}

OutgoingWebhookConnectionConfig is HTTP/TCP connection config

type OutgoingWebhookRetryConfig

type OutgoingWebhookRetryConfig struct {
	Count              *int             `json:"count"`
	Interval           *domain.Duration `json:"interval"`
	IntervalMultiplier *float64         `json:"intervalMultiplier"`
	IntervalJitter     *domain.Duration `json:"intervalJitter"`
}

OutgoingWebhookRetryConfig is retry config

type Overrides

type Overrides struct {
	BuildVersion string // Supplied by compiler
	BuildDist    string // Supplied by compiler
	BuildAt      string // UNIX epoch, supplied by compiler

	Port   int
	Listen string

	Debug bool
}

Overrides is to override configuration file.

type RedisStorageConfig

type RedisStorageConfig struct {
	SingleNode *string   `json:"singleNode"`
	Cluster    *[]string `json:"cluster"`

	DisablePubSub bool `json:"disablePubSub"`
	DisableJwt    bool `json:"disableJwt"`

	Username string `json:"username"`
	Password string `json:"password"`
	DBNumber int    `json:"db" validate:"min=0"`

	ScriptReloadInterval *domain.Duration `json:"scriptReloadInterval"`

	Timeout struct {
		Connect *domain.Duration `json:"connect"`
		Read    *domain.Duration `json:"read"`
		Write   *domain.Duration `json:"write"`
	} `json:"timeout"`

	Retry struct {
		Count          *int             `json:"count"`
		Interval       *domain.Duration `json:"interval"`
		IntervalJitter *domain.Duration `json:"intervalJitter"`
	} `json:"retry"`

	Connection struct {
		Max         *int             `json:"max"`
		Min         *int             `json:"min"`
		MaxIdleTime *domain.Duration `json:"maxIdleTime"`
	} `json:"connection"`
}

RedisStorageConfig is definition of "storage.redis" configuration

func (RedisStorageConfig) IsCluster

func (config RedisStorageConfig) IsCluster() bool

IsCluster returns true only for clustered Redis

func (RedisStorageConfig) IsSingleNode

func (config RedisStorageConfig) IsSingleNode() bool

IsSingleNode returns true only for single-node Redis

type SentryConfig

type SentryConfig struct {
	DSN string `json:"-"` // Given by environment variable

	ServerName   string `json:"serverName"`
	Environment  string `json:"environment"`
	Release      string `json:"-"` // Given by compilation time constant value
	Distribution string `json:"-"` // Given by compilation time constant value

	Tags     map[string]string `json:"tags"`
	Contexts map[string]string `json:"contexts"`

	SampleRate        *float64        `json:"sampleRate"`
	IgnoreErrors      []*domain.Regex `json:"ignoreErrors"`
	DisableStacktrace bool            `json:"disableStacktrace"`
	HideRequestData   bool            `json:"hideRequestData"`

	FlushTimeout *domain.Duration `json:"flushTimeout"`
}

SentryConfig contains Sentry configuration

func DefaultSentryConfig

func DefaultSentryConfig() *SentryConfig

DefaultSentryConfig returns empty object

type ServerConfig

type ServerConfig struct {
	BuildInfo  *BuildInfo        `json:"__buildInfo"`
	Storages   StoragesConfig    `json:"storages"`
	HTTPServer *HTTPServerConfig `json:"http"`
	Logging    *LoggingConfig    `json:"logging"`
	Telemetry  *TelemetryConfig  `json:"telemetry"`
	Sentry     *SentryConfig     `json:"sentry"`
	Channels   ChannelsConfig    `json:"channels"`
	Admin      *AdminConfig      `json:"admin"`
}

ServerConfig represents parsed/post-processed configuration.

func LoadConfigFile

func LoadConfigFile(ctx context.Context, configFile string, configOverrides Overrides) (ServerConfig, error)

LoadConfigFile load file. If configFile == "", generate default config. If configFile == "-", load from stdin.

func ParseConfig

func ParseConfig(ctx context.Context, overrides Overrides, yaml string) (ServerConfig, error)

ParseConfig constructs post-processed configuration object.

func (*ServerConfig) DumpConfig

func (config *ServerConfig) DumpConfig(w io.Writer) error

DumpConfig output config content

type StorageConfig

type StorageConfig struct {
	Onmemory *OnmemoryStorageConfig `json:"onmemory"`
	Redis    *RedisStorageConfig    `json:"redis"`
}

StorageConfig is an item of "storage" configuration section

type StoragesConfig

type StoragesConfig map[domain.StorageID]*StorageConfig

StoragesConfig is list of storage configs

func DefaultStoragesConfig

func DefaultStoragesConfig() StoragesConfig

DefaultStoragesConfig returns default configuration of storage backends

type TelemetryConfig

type TelemetryConfig struct {
	OT *OpenTelemetryConfig `json:"ot"`
}

TelemetryConfig is to setup tracing/metrics.

Jump to

Keyboard shortcuts

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