config

package
v0.1.0-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OTelProtocolGRPC = "grpc"
	OTelProtocolHTTP = "http"
)
View Source
const (
	Namespace = "Outpost"
)

Variables

View Source
var (
	ErrMismatchedServiceType = errors.New("config validation error: service type mismatch")
	ErrInvalidServiceType    = errors.New("config validation error: invalid service type")
	ErrMissingRedis          = errors.New("config validation error: redis configuration is required")
	ErrMissingLogStorage     = errors.New("config validation error: log storage must be provided")
	ErrMissingMQs            = errors.New("config validation error: message queue configuration is required")
	ErrMissingAESSecret      = errors.New("config validation error: AES encryption secret is required")
	ErrInvalidPortalProxyURL = errors.New("config validation error: invalid portal proxy url")
)
View Source
var ErrInvalidOTelProtocol = errors.New("config validation error: invalid OpenTelemetry protocol, must be 'grpc' or 'http'")

Functions

This section is empty.

Types

type AWSSQSConfig

type AWSSQSConfig struct {
	AccessKeyID     string `yaml:"access_key_id" env:"AWS_SQS_ACCESS_KEY_ID"`
	SecretAccessKey string `yaml:"secret_access_key" env:"AWS_SQS_SECRET_ACCESS_KEY"`
	Region          string `yaml:"region" env:"AWS_SQS_REGION"`
	Endpoint        string `yaml:"endpoint" env:"AWS_SQS_ENDPOINT"`
	DeliveryQueue   string `yaml:"delivery_queue" env:"AWS_SQS_DELIVERY_QUEUE"`
	LogQueue        string `yaml:"log_queue" env:"AWS_SQS_LOG_QUEUE"`
}

MQ Infrastructure configs

type AlertConfig

type AlertConfig struct {
	CallbackURL             string `yaml:"callback_url" env:"ALERT_CALLBACK_URL"`
	ConsecutiveFailureCount int    `yaml:"consecutive_failure_count" env:"ALERT_CONSECUTIVE_FAILURE_COUNT"`
	AutoDisableDestination  bool   `yaml:"auto_disable_destination" env:"ALERT_AUTO_DISABLE_DESTINATION"`
}

type ClickHouseConfig

type ClickHouseConfig struct {
	Addr     string `yaml:"addr" env:"CLICKHOUSE_ADDR"`
	Username string `yaml:"username" env:"CLICKHOUSE_USERNAME"`
	Password string `yaml:"password" env:"CLICKHOUSE_PASSWORD"`
	Database string `yaml:"database" env:"CLICKHOUSE_DATABASE"`
}

func (*ClickHouseConfig) ToConfig

type Config

type Config struct {
	Service       string              `yaml:"service" env:"SERVICE"`
	LogLevel      string              `yaml:"log_level" env:"LOG_LEVEL"`
	AuditLog      bool                `yaml:"audit_log" env:"AUDIT_LOG"`
	OpenTelemetry OpenTelemetryConfig `yaml:"otel"`
	Telemetry     TelemetryConfig     `yaml:"telemetry"`

	// API
	APIPort      int    `yaml:"api_port" env:"API_PORT"`
	APIKey       string `yaml:"api_key" env:"API_KEY"`
	APIJWTSecret string `yaml:"api_jwt_secret" env:"API_JWT_SECRET"`
	GinMode      string `yaml:"gin_mode" env:"GIN_MODE"`

	// Application
	AESEncryptionSecret string   `yaml:"aes_encryption_secret" env:"AES_ENCRYPTION_SECRET"`
	Topics              []string `yaml:"topics" env:"TOPICS" envSeparator:","`

	// Infrastructure
	Redis       RedisConfig      `yaml:"redis"`
	ClickHouse  ClickHouseConfig `yaml:"clickhouse"`
	PostgresURL string           `yaml:"postgres" env:"POSTGRES_URL"`
	MQs         MQsConfig        `yaml:"mqs"`

	// PublishMQ
	PublishMQ PublishMQConfig `yaml:"publishmq"`

	// Consumers
	PublishMaxConcurrency  int `yaml:"publish_max_concurrency" env:"PUBLISH_MAX_CONCURRENCY"`
	DeliveryMaxConcurrency int `yaml:"delivery_max_concurrency" env:"DELIVERY_MAX_CONCURRENCY"`
	LogMaxConcurrency      int `yaml:"log_max_concurrency" env:"LOG_MAX_CONCURRENCY"`

	// Delivery Retry
	RetryIntervalSeconds int `yaml:"retry_interval_seconds" env:"RETRY_INTERVAL_SECONDS"`
	RetryMaxLimit        int `yaml:"retry_max_limit" env:"MAX_RETRY_LIMIT"`

	// Event Delivery
	MaxDestinationsPerTenant int `yaml:"max_destinations_per_tenant" env:"MAX_DESTINATIONS_PER_TENANT"`
	DeliveryTimeoutSeconds   int `yaml:"delivery_timeout_seconds" env:"DELIVERY_TIMEOUT_SECONDS"`

	// Destination Registry
	DestinationMetadataPath string `yaml:"destination_metadata_path" env:"DESTINATION_METADATA_PATH"`

	// Log batcher configuration
	LogBatchThresholdSeconds int `yaml:"log_batch_threshold_seconds" env:"LOG_BATCH_THRESHOLD_SECONDS"`
	LogBatchSize             int `yaml:"log_batch_size" env:"LOG_BATCH_SIZE"`

	DisableTelemetry bool `yaml:"disable_telemetry" env:"DISABLE_TELEMETRY"`

	// Destinations
	Destinations DestinationsConfig `yaml:"destinations"`

	// Portal
	Portal PortalConfig `yaml:"portal"`

	// Alert
	Alert AlertConfig `yaml:"alert"`
	// contains filtered or unexported fields
}

func Parse

func Parse(flags Flags) (*Config, error)

Parse is the main entry point for parsing and validating config

func ParseWithOS

func ParseWithOS(flags Flags, osInterface OSInterface) (*Config, error)

ParseWithOS parses and validates config with a custom OS interface

func ParseWithoutValidation

func ParseWithoutValidation(flags Flags, osInterface OSInterface) (*Config, error)

ParseWithoutValidation parses the config without validation

func (*Config) ConfigFilePath

func (c *Config) ConfigFilePath() string

ConfigFilePath returns the path of the config file that was used

func (*Config) GetPortalConfig

func (c *Config) GetPortalConfig() portal.PortalConfig

GetPortalConfig returns the portal configuration with all necessary fields

func (*Config) GetService

func (c *Config) GetService() (ServiceType, error)

GetService returns ServiceType with error checking

func (*Config) InitDefaults

func (c *Config) InitDefaults()

func (*Config) MustGetService

func (c *Config) MustGetService() ServiceType

MustGetService returns ServiceType without error checking - panics if called before validation

func (*Config) ToMigratorOpts

func (c *Config) ToMigratorOpts() migrator.MigrationOpts

func (*Config) ToTelemetryApplicationInfo

func (c *Config) ToTelemetryApplicationInfo() telemetry.ApplicationInfo

func (*Config) Validate

func (c *Config) Validate(flags Flags) error

Validate checks if the configuration is valid

type DestinationAWSKinesisConfig

type DestinationAWSKinesisConfig struct {
	MetadataInPayload bool `yaml:"metadata_in_payload" env:"DESTINATIONS_AWS_KINESIS_METADATA_IN_PAYLOAD"`
}

AWS Kinesis configuration

type DestinationWebhookConfig

type DestinationWebhookConfig struct {
	HeaderPrefix                  string `yaml:"header_prefix" env:"DESTINATIONS_WEBHOOK_HEADER_PREFIX"`
	DisableDefaultEventIDHeader   bool   `yaml:"disable_default_event_id_header" env:"DESTINATIONS_WEBHOOK_DISABLE_DEFAULT_EVENT_ID_HEADER"`
	DisableDefaultSignatureHeader bool   `yaml:"disable_default_signature_header" env:"DESTINATIONS_WEBHOOK_DISABLE_DEFAULT_SIGNATURE_HEADER"`
	DisableDefaultTimestampHeader bool   `yaml:"disable_default_timestamp_header" env:"DESTINATIONS_WEBHOOK_DISABLE_DEFAULT_TIMESTAMP_HEADER"`
	DisableDefaultTopicHeader     bool   `yaml:"disable_default_topic_header" env:"DESTINATIONS_WEBHOOK_DISABLE_DEFAULT_TOPIC_HEADER"`
	SignatureContentTemplate      string `yaml:"signature_content_template" env:"DESTINATIONS_WEBHOOK_SIGNATURE_CONTENT_TEMPLATE"`
	SignatureHeaderTemplate       string `yaml:"signature_header_template" env:"DESTINATIONS_WEBHOOK_SIGNATURE_HEADER_TEMPLATE"`
	SignatureEncoding             string `yaml:"signature_encoding" env:"DESTINATIONS_WEBHOOK_SIGNATURE_ENCODING"`
	SignatureAlgorithm            string `yaml:"signature_algorithm" env:"DESTINATIONS_WEBHOOK_SIGNATURE_ALGORITHM"`
}

Webhook configuration

type DestinationsConfig

type DestinationsConfig struct {
	MetadataPath string                      `yaml:"metadata_path" env:"DESTINATIONS_METADATA_PATH"`
	Webhook      DestinationWebhookConfig    `yaml:"webhook"`
	AWSKinesis   DestinationAWSKinesisConfig `yaml:"aws_kinesis"`
}

DestinationsConfig is the main configuration for all destination types

func (*DestinationsConfig) ToConfig

type Flags

type Flags struct {
	Service string
	Config  string // Config file path
	Version bool   // Print version information
}

func ParseFlags

func ParseFlags() Flags

type GCPPubSubConfig

type GCPPubSubConfig struct {
	Project                   string `yaml:"project" env:"GCP_PUBSUB_PROJECT"`
	ServiceAccountCredentials string `yaml:"service_account_credentials" env:"GCP_PUBSUB_SERVICE_ACCOUNT_CREDENTIALS"`
	DeliveryTopic             string `yaml:"delivery_topic" env:"GCP_PUBSUB_DELIVERY_TOPIC"`
	DeliverySubscription      string `yaml:"delivery_subscription" env:"GCP_PUBSUB_DELIVERY_SUBSCRIPTION"`
	LogTopic                  string `yaml:"log_topic" env:"GCP_PUBSUB_LOG_TOPIC"`
	LogSubscription           string `yaml:"log_subscription" env:"GCP_PUBSUB_LOG_SUBSCRIPTION"`
}

type MQsConfig

type MQsConfig struct {
	AWSSQS    AWSSQSConfig    `yaml:"aws_sqs"`
	GCPPubSub GCPPubSubConfig `yaml:"gcp_pubsub"`
	RabbitMQ  RabbitMQConfig  `yaml:"rabbitmq"`
}

func (MQsConfig) GetDeliveryQueueConfig

func (c MQsConfig) GetDeliveryQueueConfig() *mqs.QueueConfig

func (MQsConfig) GetInfraType

func (c MQsConfig) GetInfraType() string

func (MQsConfig) GetLogQueueConfig

func (c MQsConfig) GetLogQueueConfig() *mqs.QueueConfig

type OSInterface

type OSInterface interface {
	Getenv(key string) string
	Stat(name string) (os.FileInfo, error)
	ReadFile(name string) ([]byte, error)
	Environ() []string
}

type OpenTelemetryConfig

type OpenTelemetryConfig struct {
	ServiceName string                  `yaml:"service_name" env:"OTEL_SERVICE_NAME"`
	Traces      OpenTelemetryTypeConfig `yaml:"traces"`
	Metrics     OpenTelemetryTypeConfig `yaml:"metrics"`
	Logs        OpenTelemetryTypeConfig `yaml:"logs"`
}

func (*OpenTelemetryConfig) GetServiceName

func (c *OpenTelemetryConfig) GetServiceName() string

func (*OpenTelemetryConfig) ToConfig

func (*OpenTelemetryConfig) Validate

func (c *OpenTelemetryConfig) Validate() error

type OpenTelemetryTypeConfig

type OpenTelemetryTypeConfig struct {
	Exporter string `yaml:"exporter" env:"OTEL_EXPORTER"`
	Protocol string `yaml:"protocol" env:"OTEL_PROTOCOL"`
}

type PortalConfig

type PortalConfig struct {
	ProxyURL               string `yaml:"proxy_url" env:"PORTAL_PROXY_URL"`
	RefererURL             string `yaml:"referer_url" env:"PORTAL_REFERER_URL"`
	FaviconURL             string `yaml:"favicon_url" env:"PORTAL_FAVICON_URL"`
	BrandColor             string `yaml:"brand_color" env:"PORTAL_BRAND_COLOR"`
	LogoDark               string `yaml:"logo_dark" env:"PORTAL_LOGO_DARK"`
	OrgName                string `yaml:"org_name" env:"PORTAL_ORGANIZATION_NAME"`
	ForceTheme             string `yaml:"force_theme" env:"PORTAL_FORCE_THEME"`
	DisableOutpostBranding bool   `yaml:"disable_outpost_branding" env:"PORTAL_DISABLE_OUTPOST_BRANDING"`
}

type PublishAWSSQSConfig

type PublishAWSSQSConfig struct {
	AccessKeyID     string `yaml:"access_key_id" env:"PUBLISH_AWS_SQS_ACCESS_KEY_ID"`
	SecretAccessKey string `yaml:"secret_access_key" env:"PUBLISH_AWS_SQS_SECRET_ACCESS_KEY"`
	Region          string `yaml:"region" env:"PUBLISH_AWS_SQS_REGION"`
	Endpoint        string `yaml:"endpoint" env:"PUBLISH_AWS_SQS_ENDPOINT"`
	Queue           string `yaml:"queue" env:"PUBLISH_AWS_SQS_QUEUE"`
}

type PublishGCPPubSubConfig

type PublishGCPPubSubConfig struct {
	Project                   string `yaml:"project" env:"PUBLISH_GCP_PUBSUB_PROJECT"`
	Topic                     string `yaml:"topic" env:"PUBLISH_GCP_PUBSUB_TOPIC"`
	Subscription              string `yaml:"subscription" env:"PUBLISH_GCP_PUBSUB_SUBSCRIPTION"`
	ServiceAccountCredentials string `yaml:"service_account_credentials" env:"PUBLISH_GCP_PUBSUB_SERVICE_ACCOUNT_CREDENTIALS"`
}

type PublishMQConfig

type PublishMQConfig struct {
	AWSSQS    PublishAWSSQSConfig    `yaml:"aws_sqs"`
	GCPPubSub PublishGCPPubSubConfig `yaml:"gcp_pubsub"`
	RabbitMQ  PublishRabbitMQConfig  `yaml:"rabbitmq"`
}

func (PublishMQConfig) GetInfraType

func (c PublishMQConfig) GetInfraType() string

func (*PublishMQConfig) GetQueueConfig

func (c *PublishMQConfig) GetQueueConfig() *mqs.QueueConfig

type PublishRabbitMQConfig

type PublishRabbitMQConfig struct {
	ServerURL string `yaml:"server_url" env:"PUBLISH_RABBITMQ_SERVER_URL"`
	Exchange  string `yaml:"exchange" env:"PUBLISH_RABBITMQ_EXCHANGE"`
	Queue     string `yaml:"queue" env:"PUBLISH_RABBITMQ_QUEUE"`
}

type RabbitMQConfig

type RabbitMQConfig struct {
	ServerURL     string `yaml:"server_url" env:"RABBITMQ_SERVER_URL"`
	Exchange      string `yaml:"exchange" env:"RABBITMQ_EXCHANGE"`
	DeliveryQueue string `yaml:"delivery_queue" env:"RABBITMQ_DELIVERY_QUEUE"`
	LogQueue      string `yaml:"log_queue" env:"RABBITMQ_LOG_QUEUE"`
}

type RedisConfig

type RedisConfig struct {
	Host     string `yaml:"host" env:"REDIS_HOST"`
	Port     int    `yaml:"port" env:"REDIS_PORT"`
	Password string `yaml:"password" env:"REDIS_PASSWORD"`
	Database int    `yaml:"database" env:"REDIS_DATABASE"`
}

func (*RedisConfig) ToConfig

func (c *RedisConfig) ToConfig() *redis.RedisConfig

type ServiceType

type ServiceType int
const (
	ServiceTypeAll ServiceType = iota
	ServiceTypeAPI
	ServiceTypeLog
	ServiceTypeDelivery
)

func ServiceTypeFromString

func ServiceTypeFromString(s string) (ServiceType, error)

func (ServiceType) String

func (s ServiceType) String() string

type TelemetryConfig

type TelemetryConfig struct {
	Disabled          bool   `yaml:"disabled" env:"DISABLE_TELEMETRY"`
	BatchSize         int    `yaml:"batch_size" env:"TELEMETRY_BATCH_SIZE"`
	BatchInterval     int    `yaml:"batch_interval" env:"TELEMETRY_BATCH_INTERVAL"`
	HookdeckSourceURL string `yaml:"hookdeck_source_url" env:"TELEMETRY_HOOKDECK_SOURCE_URL"`
	SentryDSN         string `yaml:"sentry_dsn" env:"TELEMETRY_SENTRY_DSN"`
}

func (*TelemetryConfig) ToTelemetryConfig

func (c *TelemetryConfig) ToTelemetryConfig() telemetry.TelemetryConfig

Jump to

Keyboard shortcuts

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