config

package
v1.0.0-beta.106 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 34 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 ConfigureDedupe

func ConfigureDedupe(v *viper.Viper)

ConfigureDedupe configures some defaults in the Viper instance.

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 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 ClickHouseAggregationConfiguration

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

func (ClickHouseAggregationConfiguration) Validate

type Configuration

type Configuration struct {
	Address     string
	Environment string

	Telemetry TelemetryConfig

	Aggregation  AggregationConfiguration
	Entitlements EntitlementsConfiguration
	Dedupe       DedupeConfiguration
	Ingest       IngestConfiguration
	Meters       []*models.Meter
	Namespace    NamespaceConfiguration
	Portal       PortalConfiguration
	Postgres     PostgresConfig
	Sink         SinkConfiguration
}

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 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 {
	Address    string
	Database   int
	Username   string
	Password   string
	Expiration time.Duration
	Sentinel   struct {
		Enabled    bool
		MasterName string
	}
	TLS struct {
		Enabled            bool
		InsecureSkipVerify bool
	}
}

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 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 KafkaIngestConfiguration

type KafkaIngestConfiguration struct {
	Broker              string
	SecurityProtocol    string
	SaslMechanisms      string
	SaslUsername        string
	SaslPassword        string
	Partitions          int
	EventsTopicTemplate 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
}

func (KafkaIngestConfiguration) CreateKafkaConfig

func (c KafkaIngestConfiguration) CreateKafkaConfig() kafka.ConfigMap

CreateKafkaConfig creates a Kafka config map.

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 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 SinkConfiguration

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

func (SinkConfiguration) Validate

func (c SinkConfiguration) Validate() error

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