Documentation
¶
Overview ¶
Package config loads application configuration.
Index ¶
- func ConfigureAggregation(v *viper.Viper)
- func ConfigureBalanceWorker(v *viper.Viper)
- func ConfigureConsumer(v *viper.Viper, prefix string)
- func ConfigureDedupe(v *viper.Viper)
- func ConfigureEvents(v *viper.Viper)
- func ConfigureIngest(v *viper.Viper)
- func ConfigureNamespace(v *viper.Viper)
- func ConfigureNotification(v *viper.Viper)
- func ConfigurePortal(v *viper.Viper)
- func ConfigureSink(v *viper.Viper)
- func DecodeHook() mapstructure.DecodeHookFunc
- func SetViperDefaults(v *viper.Viper, flags *pflag.FlagSet)
- type AggregationConfiguration
- type AutoProvisionConfiguration
- type BalanceWorkerConfiguration
- type ClickHouseAggregationConfiguration
- type Configuration
- type ConsumerConfiguration
- type DLQAutoProvisionConfiguration
- type DLQConfiguration
- type DedupeConfiguration
- type DedupeDriverConfiguration
- type DedupeDriverMemoryConfiguration
- type DedupeDriverRedisConfiguration
- type EntitlementsConfiguration
- type EventSubsystemConfiguration
- type EventsConfiguration
- type ExportersMetricsTelemetryConfig
- type ExportersTraceTelemetryConfig
- type IngestConfiguration
- type IngestNotificationsConfiguration
- type KafkaConfiguration
- type KafkaIngestConfiguration
- type LogTelemetryConfiguration
- type MetricsTelemetryConfig
- type NamespaceConfiguration
- type NotificationConfiguration
- type OTLPExporterTelemetryConfig
- type OTLPExportersMetricsTelemetryConfig
- type OTLPExportersTraceTelemetryConfig
- type PortalCORSConfiguration
- type PortalConfiguration
- type PostgresConfig
- type PrometheusExportersMetricsTelemetryConfig
- type RetryConfiguration
- type SinkConfiguration
- type SvixConfig
- type TelemetryConfig
- type TraceTelemetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureAggregation ¶
ConfigureAggregation configures some defaults in the Viper instance.
func ConfigureBalanceWorker ¶
func ConfigureConsumer ¶
func ConfigureDedupe ¶
ConfigureDedupe configures some defaults in the Viper instance.
func ConfigureEvents ¶
func ConfigureIngest ¶
Configure configures some defaults in the Viper instance.
func ConfigureNamespace ¶
ConfigureNamespace configures some defaults in the Viper instance.
func ConfigureNotification ¶
func ConfigurePortal ¶
ConfigurePortal configures some defaults in the Viper instance.
func ConfigureSink ¶
Configure configures some defaults in the Viper instance.
func DecodeHook ¶
func DecodeHook() mapstructure.DecodeHookFunc
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 ¶
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 ¶
func (c ClickHouseAggregationConfiguration) Validate() error
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 ¶
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 ¶
Dedupe memory driver configuration
func (DedupeDriverMemoryConfiguration) DriverName ¶
func (DedupeDriverMemoryConfiguration) DriverName() string
func (DedupeDriverMemoryConfiguration) NewDeduplicator ¶
func (c DedupeDriverMemoryConfiguration) NewDeduplicator() (dedupe.Deduplicator, error)
func (DedupeDriverMemoryConfiguration) Validate ¶
func (c DedupeDriverMemoryConfiguration) Validate() error
type DedupeDriverRedisConfiguration ¶
type DedupeDriverRedisConfiguration struct {
redis.Config `mapstructure:",squash"`
Expiration time.Duration
}
Dedupe redis driver configuration
func (DedupeDriverRedisConfiguration) DriverName ¶
func (DedupeDriverRedisConfiguration) DriverName() string
func (DedupeDriverRedisConfiguration) NewDeduplicator ¶
func (c DedupeDriverRedisConfiguration) NewDeduplicator() (dedupe.Deduplicator, error)
func (DedupeDriverRedisConfiguration) Validate ¶
func (c DedupeDriverRedisConfiguration) Validate() error
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 ¶
func (c ExportersMetricsTelemetryConfig) Validate() error
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 ¶
func (c IngestNotificationsConfiguration) Validate() error
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 ¶
func (c LogTelemetryConfiguration) NewHandler(w io.Writer) slog.Handler
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 (c MetricsTelemetryConfig) NewMeterProvider(ctx context.Context, res *resource.Resource) (*sdkmetric.MeterProvider, error)
func (MetricsTelemetryConfig) Validate ¶
func (c MetricsTelemetryConfig) Validate() error
Validate validates the configuration.
type NamespaceConfiguration ¶
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 (c OTLPExporterTelemetryConfig) DialExporter(ctx context.Context) (*grpc.ClientConn, error)
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 ¶
func (c OTLPExportersMetricsTelemetryConfig) NewExporter(ctx context.Context) (sdkmetric.Reader, error)
NewExporter creates a new sdkmetric.Reader.
func (OTLPExportersMetricsTelemetryConfig) Validate ¶
func (c OTLPExportersMetricsTelemetryConfig) Validate() error
Validate validates the configuration.
type OTLPExportersTraceTelemetryConfig ¶
type OTLPExportersTraceTelemetryConfig struct {
Enabled bool
OTLPExporterTelemetryConfig `mapstructure:",squash"`
}
func (OTLPExportersTraceTelemetryConfig) NewExporter ¶
func (c OTLPExportersTraceTelemetryConfig) NewExporter(ctx context.Context) (sdktrace.SpanExporter, error)
NewExporter creates a new sdktrace.SpanExporter.
func (OTLPExportersTraceTelemetryConfig) Validate ¶
func (c OTLPExportersTraceTelemetryConfig) Validate() error
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 ¶
func (c PrometheusExportersMetricsTelemetryConfig) NewExporter() (sdkmetric.Reader, error)
NewExporter creates a new sdkmetric.Reader.
func (PrometheusExportersMetricsTelemetryConfig) Validate ¶
func (c PrometheusExportersMetricsTelemetryConfig) Validate() error
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 (c TraceTelemetryConfig) NewTracerProvider(ctx context.Context, res *resource.Resource) (*sdktrace.TracerProvider, error)
func (TraceTelemetryConfig) Validate ¶
func (c TraceTelemetryConfig) Validate() error
Validate validates the configuration.