config

package
v1.0.0-beta.164 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package config loads application configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureAggregation

func ConfigureAggregation(v *viper.Viper)

ConfigureAggregation configures some defaults in the Viper instance.

func ConfigureBalanceWorker

func ConfigureBalanceWorker(v *viper.Viper)

func ConfigureConsumer

func ConfigureConsumer(v *viper.Viper, prefix string)

func ConfigureDedupe

func ConfigureDedupe(v *viper.Viper)

ConfigureDedupe configures some defaults in the Viper instance.

func ConfigureEvents

func ConfigureEvents(v *viper.Viper)

func ConfigureIngest

func ConfigureIngest(v *viper.Viper)

Configure configures some defaults in the Viper instance.

func ConfigureNamespace

func ConfigureNamespace(v *viper.Viper)

ConfigureNamespace configures some defaults in the Viper instance.

func ConfigureNotification

func ConfigureNotification(v *viper.Viper)

func ConfigurePortal

func ConfigurePortal(v *viper.Viper)

ConfigurePortal configures some defaults in the Viper instance.

func ConfigureSink

func ConfigureSink(v *viper.Viper)

Configure configures some defaults in the Viper instance.

func DecodeHook

func DecodeHook() mapstructure.DecodeHookFunc

func SetViperDefaults

func SetViperDefaults(v *viper.Viper, flags *pflag.FlagSet)

Types

type AggregationConfiguration

type AggregationConfiguration struct {
	ClickHouse ClickHouseAggregationConfiguration
	// Populate creates the materialized view with data from the events table
	// This is not safe to use in production as requires to stop ingestion
	PopulateMeter bool
	// CreateOrReplace is used to force the recreation of the materialized view
	// This is not safe to use in production as it will drop the existing views
	CreateOrReplaceMeter bool
}

func (AggregationConfiguration) Validate

func (c AggregationConfiguration) Validate() error

Validate validates the configuration.

type AutoProvisionConfiguration

type AutoProvisionConfiguration struct {
	Enabled      bool
	Partitions   int
	DLQRetention time.Duration
}

func (AutoProvisionConfiguration) Validate

func (c AutoProvisionConfiguration) Validate() error

type BalanceWorkerConfiguration

type BalanceWorkerConfiguration struct {
	ConsumerConfiguration `mapstructure:",squash"`
}

func (BalanceWorkerConfiguration) Validate

func (c BalanceWorkerConfiguration) Validate() error

type ClickHouseAggregationConfiguration

type ClickHouseAggregationConfiguration struct {
	Address  string
	TLS      bool
	Username string
	Password string
	Database string
}

func (ClickHouseAggregationConfiguration) GetClientOptions

func (c ClickHouseAggregationConfiguration) GetClientOptions() *clickhouse.Options

func (ClickHouseAggregationConfiguration) Validate

type Configuration

type Configuration struct {
	Address     string
	Environment string

	Telemetry TelemetryConfig

	Aggregation   AggregationConfiguration
	Entitlements  EntitlementsConfiguration
	Dedupe        DedupeConfiguration
	Events        EventsConfiguration
	Ingest        IngestConfiguration
	Meters        []*models.Meter
	Namespace     NamespaceConfiguration
	Portal        PortalConfiguration
	Postgres      PostgresConfig
	Sink          SinkConfiguration
	BalanceWorker BalanceWorkerConfiguration
	Notification  NotificationConfiguration
	Svix          SvixConfig
}

Configuration holds any kind of Configuration that comes from the outside world and is necessary for running the application.

func (Configuration) Validate

func (c Configuration) Validate() error

Validate validates the configuration.

type ConsumerConfiguration

type ConsumerConfiguration struct {
	// ProcessingTimeout is the maximum time a message is allowed to be processed before it is considered failed. 0 disables the timeout.
	ProcessingTimeout time.Duration

	// Retry specifies how many times a message should be retried before it is sent to the DLQ.
	Retry RetryConfiguration

	// ConsumerGroupName is the name of the consumer group that the consumer belongs to.
	ConsumerGroupName string

	// DLQ specifies the configuration for the Dead Letter Queue.
	DLQ DLQConfiguration
}

func (ConsumerConfiguration) Validate

func (c ConsumerConfiguration) Validate() error

type DLQAutoProvisionConfiguration

type DLQAutoProvisionConfiguration struct {
	Enabled    bool
	Partitions int
	Retention  time.Duration
}

func (DLQAutoProvisionConfiguration) Validate

func (c DLQAutoProvisionConfiguration) Validate() error

type DLQConfiguration

type DLQConfiguration struct {
	Enabled       bool
	Topic         string
	AutoProvision DLQAutoProvisionConfiguration
}

func (DLQConfiguration) Validate

func (c DLQConfiguration) Validate() error

type DedupeConfiguration

type DedupeConfiguration struct {
	Enabled bool

	DedupeDriverConfiguration
}

Requires mapstructurex.MapDecoderHookFunc to be high up in the decode hook chain.

func (*DedupeConfiguration) DecodeMap

func (c *DedupeConfiguration) DecodeMap(v map[string]any) error

func (DedupeConfiguration) NewDeduplicator

func (c DedupeConfiguration) NewDeduplicator() (dedupe.Deduplicator, error)

func (DedupeConfiguration) Validate

func (c DedupeConfiguration) Validate() error

type DedupeDriverConfiguration

type DedupeDriverConfiguration interface {
	DriverName() string
	NewDeduplicator() (dedupe.Deduplicator, error)
	Validate() error
}

type DedupeDriverMemoryConfiguration

type DedupeDriverMemoryConfiguration struct {
	Enabled bool
	Size    int
}

Dedupe memory driver configuration

func (DedupeDriverMemoryConfiguration) DriverName

func (DedupeDriverMemoryConfiguration) NewDeduplicator

func (DedupeDriverMemoryConfiguration) Validate

type DedupeDriverRedisConfiguration

type DedupeDriverRedisConfiguration struct {
	redis.Config `mapstructure:",squash"`

	Expiration time.Duration
}

Dedupe redis driver configuration

func (DedupeDriverRedisConfiguration) DriverName

func (DedupeDriverRedisConfiguration) NewDeduplicator

func (DedupeDriverRedisConfiguration) Validate

type EntitlementsConfiguration

type EntitlementsConfiguration struct {
	Enabled bool
}

func (EntitlementsConfiguration) Validate

func (c EntitlementsConfiguration) Validate() error

Validate validates the configuration.

type EventSubsystemConfiguration

type EventSubsystemConfiguration struct {
	Enabled bool
	Topic   string

	AutoProvision AutoProvisionConfiguration
}

func (EventSubsystemConfiguration) Validate

func (c EventSubsystemConfiguration) Validate() error

type EventsConfiguration

type EventsConfiguration struct {
	Enabled      bool
	SystemEvents EventSubsystemConfiguration
	IngestEvents EventSubsystemConfiguration
}

func (EventsConfiguration) Validate

func (c EventsConfiguration) Validate() error

type ExportersMetricsTelemetryConfig

type ExportersMetricsTelemetryConfig struct {
	Prometheus PrometheusExportersMetricsTelemetryConfig
	OTLP       OTLPExportersMetricsTelemetryConfig
}

func (ExportersMetricsTelemetryConfig) Validate

Validate validates the configuration.

type ExportersTraceTelemetryConfig

type ExportersTraceTelemetryConfig struct {
	OTLP OTLPExportersTraceTelemetryConfig
}

func (ExportersTraceTelemetryConfig) Validate

func (c ExportersTraceTelemetryConfig) Validate() error

Validate validates the configuration.

type IngestConfiguration

type IngestConfiguration struct {
	Kafka KafkaIngestConfiguration
}

func (IngestConfiguration) Validate

func (c IngestConfiguration) Validate() error

Validate validates the configuration.

type IngestNotificationsConfiguration

type IngestNotificationsConfiguration struct {
	MaxEventsInBatch int
}

func (IngestNotificationsConfiguration) Validate

type KafkaConfiguration

type KafkaConfiguration struct {
	Broker           string
	SecurityProtocol string
	SaslMechanisms   string
	SaslUsername     string
	SaslPassword     string

	StatsInterval pkgkafka.TimeDurationMilliSeconds

	// BrokerAddressFamily defines the IP address family to be used for network communication with Kafka cluster
	BrokerAddressFamily pkgkafka.BrokerAddressFamily
	// SocketKeepAliveEnable defines if TCP socket keep-alive is enabled to prevent closing idle connections
	// by Kafka brokers.
	SocketKeepAliveEnabled bool
	// TopicMetadataRefreshInterval defines how frequently the Kafka client needs to fetch metadata information
	// (brokers, topic, partitions, etc) from the Kafka cluster.
	// The 5 minutes default value is appropriate for mostly static Kafka clusters, but needs to be lowered
	// in case of large clusters where changes are more frequent.
	// This value must not be set to value lower than 10s.
	TopicMetadataRefreshInterval pkgkafka.TimeDurationMilliSeconds

	// Enable contexts for extensive debugging of librdkafka.
	// See: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md#debug-contexts
	DebugContexts pkgkafka.DebugContexts
}

func (KafkaConfiguration) CreateKafkaConfig

func (c KafkaConfiguration) CreateKafkaConfig() kafka.ConfigMap

CreateKafkaConfig creates a Kafka config map.

func (KafkaConfiguration) Validate

func (c KafkaConfiguration) Validate() error

type KafkaIngestConfiguration

type KafkaIngestConfiguration struct {
	KafkaConfiguration `mapstructure:",squash"`

	Partitions          int
	EventsTopicTemplate string
}

func (KafkaIngestConfiguration) Validate

func (c KafkaIngestConfiguration) Validate() error

Validate validates the configuration.

type LogTelemetryConfiguration

type LogTelemetryConfiguration struct {
	// Format specifies the output log format.
	// Accepted values are: json, text
	Format string

	// Level is the minimum log level that should appear on the output.
	//
	// Requires [mapstructure.TextUnmarshallerHookFunc] to be high up in the decode hook chain.
	Level slog.Level
}

func (LogTelemetryConfiguration) NewHandler

NewHandler creates a new slog.Handler.

func (LogTelemetryConfiguration) Validate

func (c LogTelemetryConfiguration) Validate() error

Validate validates the configuration.

type MetricsTelemetryConfig

type MetricsTelemetryConfig struct {
	Exporters ExportersMetricsTelemetryConfig
}

func (MetricsTelemetryConfig) NewMeterProvider

func (MetricsTelemetryConfig) Validate

func (c MetricsTelemetryConfig) Validate() error

Validate validates the configuration.

type NamespaceConfiguration

type NamespaceConfiguration struct {
	Default           string
	DisableManagement bool
}

Namespace configuration

func (NamespaceConfiguration) Validate

func (c NamespaceConfiguration) Validate() error

type NotificationConfiguration

type NotificationConfiguration struct {
	Enabled  bool
	Consumer ConsumerConfiguration
}

func (NotificationConfiguration) Validate

func (c NotificationConfiguration) Validate() error

type OTLPExporterTelemetryConfig

type OTLPExporterTelemetryConfig struct {
	Address string
}

func (OTLPExporterTelemetryConfig) DialExporter

func (OTLPExporterTelemetryConfig) Validate

func (c OTLPExporterTelemetryConfig) Validate() error

Validate validates the configuration.

type OTLPExportersMetricsTelemetryConfig

type OTLPExportersMetricsTelemetryConfig struct {
	Enabled bool

	OTLPExporterTelemetryConfig `mapstructure:",squash"`
}

func (OTLPExportersMetricsTelemetryConfig) NewExporter

NewExporter creates a new sdkmetric.Reader.

func (OTLPExportersMetricsTelemetryConfig) Validate

Validate validates the configuration.

type OTLPExportersTraceTelemetryConfig

type OTLPExportersTraceTelemetryConfig struct {
	Enabled bool

	OTLPExporterTelemetryConfig `mapstructure:",squash"`
}

func (OTLPExportersTraceTelemetryConfig) NewExporter

NewExporter creates a new sdktrace.SpanExporter.

func (OTLPExportersTraceTelemetryConfig) Validate

Validate validates the configuration.

type PortalCORSConfiguration

type PortalCORSConfiguration struct {
	Enabled bool `mapstructure:"enabled"`
}

type PortalConfiguration

type PortalConfiguration struct {
	Enabled         bool                    `mapstructure:"enabled"`
	CORS            PortalCORSConfiguration `mapstructure:"cors"`
	TokenSecret     string                  `mapstructure:"tokenSecret"`
	TokenExpiration time.Duration           `mapstructure:"tokenExpiration"`
}

func (PortalConfiguration) Validate

func (c PortalConfiguration) Validate() error

Validate validates the configuration.

type PostgresConfig

type PostgresConfig struct {
	// URL is the PostgreSQL database connection URL.
	URL string `yaml:"url"`
}

func (PostgresConfig) Validate

func (c PostgresConfig) Validate() error

Validate validates the configuration.

type PrometheusExportersMetricsTelemetryConfig

type PrometheusExportersMetricsTelemetryConfig struct {
	Enabled bool
}

func (PrometheusExportersMetricsTelemetryConfig) NewExporter

NewExporter creates a new sdkmetric.Reader.

func (PrometheusExportersMetricsTelemetryConfig) Validate

Validate validates the configuration.

type RetryConfiguration

type RetryConfiguration struct {
	// MaxRetries is maximum number of times a retry will be attempted. Disabled if 0
	MaxRetries int
	// InitialInterval is the first interval between retries. Subsequent intervals will be scaled by Multiplier.
	InitialInterval time.Duration
	// MaxInterval sets the limit for the exponential backoff of retries. The interval will not be increased beyond MaxInterval.
	MaxInterval time.Duration
	// MaxElapsedTime sets the time limit of how long retries will be attempted. Disabled if 0.
	MaxElapsedTime time.Duration
}

func (RetryConfiguration) Validate

func (c RetryConfiguration) Validate() error

type SinkConfiguration

type SinkConfiguration struct {
	GroupId             string
	Dedupe              DedupeConfiguration
	MinCommitCount      int
	MaxCommitWait       time.Duration
	NamespaceRefetch    time.Duration
	IngestNotifications IngestNotificationsConfiguration
}

func (SinkConfiguration) Validate

func (c SinkConfiguration) Validate() error

type SvixConfig

type SvixConfig = notificationwebhook.SvixConfig

type TelemetryConfig

type TelemetryConfig struct {
	// Telemetry HTTP server address
	Address string

	Trace TraceTelemetryConfig

	Metrics MetricsTelemetryConfig

	Log LogTelemetryConfiguration
}

func (TelemetryConfig) Validate

func (c TelemetryConfig) Validate() error

Validate validates the configuration.

type TraceTelemetryConfig

type TraceTelemetryConfig struct {
	Sampler   string
	Exporters ExportersTraceTelemetryConfig
}

func (TraceTelemetryConfig) GetSampler

func (c TraceTelemetryConfig) GetSampler() sdktrace.Sampler

func (TraceTelemetryConfig) NewTracerProvider

func (TraceTelemetryConfig) Validate

func (c TraceTelemetryConfig) Validate() error

Validate validates the configuration.

Jump to

Keyboard shortcuts

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