config

package
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyConfig

type APIKeyConfig struct {
	Header string                   `mapstructure:"header" validate:"required" default:"x-api-key"`
	Keys   map[string]APIKeyDetails `mapstructure:"keys"` // map of hashed API key to its details
}

type APIKeyDetails

type APIKeyDetails struct {
	TenantID string `mapstructure:"tenant_id" json:"tenant_id" validate:"required"`
	UserID   string `mapstructure:"user_id" json:"user_id" validate:"required"`
	Name     string `mapstructure:"name" json:"name" validate:"required"`      // description of what this key is for
	IsActive bool   `mapstructure:"is_active" json:"is_active" default:"true"` // whether this key is active
}

type AuthConfig

type AuthConfig struct {
	Provider types.AuthProvider `mapstructure:"provider" validate:"required"`
	Secret   string             `mapstructure:"secret" validate:"required"`
	Supabase SupabaseConfig     `mapstructure:"supabase"`
	APIKey   APIKeyConfig       `mapstructure:"api_key"`
}

type BillingConfig added in v1.0.0

type BillingConfig struct {
	TenantID      string `mapstructure:"tenant_id" validate:"omitempty"`
	EnvironmentID string `mapstructure:"environment_id" validate:"omitempty"`
}

type BucketConfig added in v1.0.13

type BucketConfig struct {
	Bucket                string `mapstructure:"bucket" validate:"required"`
	PresignExpiryDuration string `mapstructure:"presign_expiry_duration" validate:"required"`
	KeyPrefix             string `mapstructure:"key_prefix" validate:"omitempty"`
}

type CacheConfig added in v1.0.17

type CacheConfig struct {
	Enabled bool `mapstructure:"enabled" validate:"required"`
}

type ClickHouseConfig

type ClickHouseConfig struct {
	Address  string `mapstructure:"address" validate:"required"`
	TLS      bool   `mapstructure:"tls"`
	Username string `mapstructure:"username" validate:"required"`
	Password string `mapstructure:"password" validate:"required"`
	Database string `mapstructure:"database" validate:"required"`
}

func (ClickHouseConfig) GetClientOptions

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

type Configuration

type Configuration struct {
	Deployment               DeploymentConfig               `validate:"required"`
	Server                   ServerConfig                   `validate:"required"`
	Auth                     AuthConfig                     `validate:"required"`
	Kafka                    KafkaConfig                    `validate:"required"`
	ClickHouse               ClickHouseConfig               `validate:"required"`
	Logging                  LoggingConfig                  `validate:"required"`
	Postgres                 PostgresConfig                 `validate:"required"`
	Sentry                   SentryConfig                   `validate:"required"`
	Pyroscope                PyroscopeConfig                `validate:"required"`
	Event                    EventConfig                    `validate:"required"`
	DynamoDB                 DynamoDBConfig                 `validate:"required"`
	Temporal                 TemporalConfig                 `validate:"required"`
	Webhook                  Webhook                        `validate:"omitempty"`
	Secrets                  SecretsConfig                  `validate:"required"`
	Billing                  BillingConfig                  `validate:"omitempty"`
	S3                       S3Config                       `validate:"required"`
	Cache                    CacheConfig                    `validate:"required"`
	EventProcessing          EventProcessingConfig          `mapstructure:"event_processing" validate:"required"`
	EventProcessingLazy      EventProcessingLazyConfig      `mapstructure:"event_processing_lazy" validate:"required"`
	EventPostProcessing      EventPostProcessingConfig      `mapstructure:"event_post_processing" validate:"required"`
	FeatureUsageTracking     FeatureUsageTrackingConfig     `mapstructure:"feature_usage_tracking" validate:"required"`
	FeatureUsageTrackingLazy FeatureUsageTrackingLazyConfig `mapstructure:"feature_usage_tracking_lazy" validate:"required"`
	EnvAccess                EnvAccessConfig                `mapstructure:"env_access" json:"env_access" validate:"omitempty"`
	FeatureFlag              FeatureFlagConfig              `mapstructure:"feature_flag" validate:"required"`
	Email                    EmailConfig                    `mapstructure:"email" validate:"required"`
}

func GetDefaultConfig

func GetDefaultConfig() *Configuration

GetDefaultConfig returns a default configuration for local development This is useful for running scripts or other non-web applications

func NewConfig

func NewConfig() (*Configuration, error)

func (Configuration) Validate

func (c Configuration) Validate() error

type DeploymentConfig

type DeploymentConfig struct {
	Mode types.RunMode `mapstructure:"mode" validate:"required"`
}

type DynamoDBConfig

type DynamoDBConfig struct {
	InUse          bool   `mapstructure:"in_use" validate:"required" default:"false"`
	Region         string `mapstructure:"region"`
	EventTableName string `mapstructure:"event_table_name"`
}

DynamoDBConfig holds configuration for DynamoDB

type Email added in v1.0.32

type Email struct {
	Enabled      bool   `mapstructure:"enabled" validate:"required"`
	ResendAPIKey string `mapstructure:"resend_api_key" validate:"omitempty"`
	FromAddress  string `mapstructure:"from_address" validate:"omitempty"`
	ReplyTo      string `mapstructure:"reply_to" validate:"omitempty"`
	CalendarURL  string `mapstructure:"calendar_url" validate:"omitempty"`
}

type EmailConfig added in v1.0.32

type EmailConfig struct {
	Enabled      bool   `mapstructure:"enabled" validate:"required"`
	ResendAPIKey string `mapstructure:"resend_api_key" validate:"omitempty"`
	FromAddress  string `mapstructure:"from_address" validate:"omitempty"`
	ReplyTo      string `mapstructure:"reply_to" validate:"omitempty"`
	CalendarURL  string `mapstructure:"calendar_url" validate:"omitempty"`
}

type EnvAccessConfig added in v1.0.18

type EnvAccessConfig struct {
	UserEnvMapping map[string]map[string][]string `mapstructure:"user_env_mapping" json:"user_env_mapping" validate:"omitempty"`
}

type EventConfig

type EventConfig struct {
	PublishDestination types.PublishDestination `mapstructure:"publish_destination" default:"kafka"`
}

EventConfig holds configuration for event processing

type EventPostProcessingConfig added in v1.0.17

type EventPostProcessingConfig struct {
	// Rate limit in messages consumed per second
	Topic                 string `mapstructure:"topic" default:"events_post_processing"`
	RateLimit             int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup         string `mapstructure:"consumer_group" default:"v1_events_post_processing"`
	TopicBackfill         string `mapstructure:"topic_backfill" default:"v1_events_post_processing_backfill"`
	RateLimitBackfill     int64  `mapstructure:"rate_limit_backfill" default:"1"`
	ConsumerGroupBackfill string `mapstructure:"consumer_group_backfill" default:"v1_events_post_processing_backfill"`
}

type EventProcessingConfig added in v1.0.31

type EventProcessingConfig struct {
	// Rate limit in messages consumed per second
	Topic                 string `mapstructure:"topic" default:"events"`
	RateLimit             int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup         string `mapstructure:"consumer_group" default:"v1_event_processing"`
	TopicBackfill         string `mapstructure:"topic_backfill" default:"event_processing_backfill"`
	RateLimitBackfill     int64  `mapstructure:"rate_limit_backfill" default:"1"`
	ConsumerGroupBackfill string `mapstructure:"consumer_group_backfill" default:"v1_event_processing_backfill"`
}

type EventProcessingLazyConfig added in v1.0.31

type EventProcessingLazyConfig struct {
	Topic                 string `mapstructure:"topic" default:"events_lazy"`
	RateLimit             int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup         string `mapstructure:"consumer_group" default:"v1_event_processing_lazy"`
	TopicBackfill         string `mapstructure:"topic_backfill" default:"event_processing_lazy_backfill"`
	RateLimitBackfill     int64  `mapstructure:"rate_limit_backfill" default:"1"`
	ConsumerGroupBackfill string `mapstructure:"consumer_group_backfill" default:"v1_event_processing_lazy_backfill"`
}

type FeatureFlagConfig added in v1.0.29

type FeatureFlagConfig struct {
	EnableFeatureUsageForAnalytics bool   `mapstructure:"enable_feature_usage_for_analytics" validate:"required"`
	ForceV1ForTenant               string `mapstructure:"force_v1_for_tenant" validate:"omitempty"`
}

type FeatureUsageTrackingConfig added in v1.0.27

type FeatureUsageTrackingConfig struct {
	// Rate limit in messages consumed per second
	Topic                 string `mapstructure:"topic" default:"events"`
	RateLimit             int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup         string `mapstructure:"consumer_group" default:"v1_feature_tracking_service"`
	TopicBackfill         string `mapstructure:"topic_backfill" default:"v1_feature_tracking_service_backfill"`
	RateLimitBackfill     int64  `mapstructure:"rate_limit_backfill" default:"1"`
	ConsumerGroupBackfill string `mapstructure:"consumer_group_backfill" default:"v1_feature_tracking_service_backfill"`
}

type FeatureUsageTrackingLazyConfig added in v1.0.31

type FeatureUsageTrackingLazyConfig struct {
	Topic                 string `mapstructure:"topic" default:"events_lazy"`
	RateLimit             int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup         string `mapstructure:"consumer_group" default:"v1_feature_tracking_service_realtime"`
	TopicBackfill         string `mapstructure:"topic_backfill" default:"v1_feature_tracking_service_lazy_backfill"`
	RateLimitBackfill     int64  `mapstructure:"rate_limit_backfill" default:"1"`
	ConsumerGroupBackfill string `mapstructure:"consumer_group_backfill" default:"v1_feature_tracking_service_lazy_backfill"`
}

type KafkaConfig

type KafkaConfig struct {
	Brokers                []string             `mapstructure:"brokers" validate:"required"`
	ConsumerGroup          string               `mapstructure:"consumer_group" validate:"required"`
	Topic                  string               `mapstructure:"topic" validate:"required"`
	TopicLazy              string               `mapstructure:"topic_lazy" validate:"required"`
	TLS                    bool                 `mapstructure:"tls"` // set to true if using 9094 port else can set to false
	UseSASL                bool                 `mapstructure:"use_sasl"`
	SASLMechanism          sarama.SASLMechanism `mapstructure:"sasl_mechanism"`
	SASLUser               string               `mapstructure:"sasl_user"`
	SASLPassword           string               `mapstructure:"sasl_password"`
	ClientID               string               `mapstructure:"client_id" validate:"required"`
	RouteTenantsOnLazyMode []string             `mapstructure:"route_tenants_on_lazy_mode" validate:"omitempty"`
}

type LoggingConfig

type LoggingConfig struct {
	Level types.LogLevel `mapstructure:"level" validate:"required"`
}

type PostgresConfig

type PostgresConfig struct {
	Host                   string `mapstructure:"host" validate:"required"`
	Port                   int    `mapstructure:"port" validate:"required"`
	User                   string `mapstructure:"user" validate:"required"`
	Password               string `mapstructure:"password" validate:"required"`
	DBName                 string `mapstructure:"dbname" validate:"required"`
	SSLMode                string `mapstructure:"sslmode" validate:"required"`
	MaxOpenConns           int    `mapstructure:"max_open_conns" default:"10"`
	MaxIdleConns           int    `mapstructure:"max_idle_conns" default:"5"`
	ConnMaxLifetimeMinutes int    `mapstructure:"conn_max_lifetime_minutes" default:"60"`
	AutoMigrate            bool   `mapstructure:"auto_migrate" default:"false"`

	// Reader endpoint configuration for read replicas
	ReaderHost string `mapstructure:"reader_host"`
	ReaderPort int    `mapstructure:"reader_port"`
}

func (PostgresConfig) GetDSN

func (c PostgresConfig) GetDSN() string

func (PostgresConfig) GetReaderDSN added in v1.0.32

func (c PostgresConfig) GetReaderDSN() string

func (PostgresConfig) HasSeparateReader added in v1.0.32

func (c PostgresConfig) HasSeparateReader() bool

type PyroscopeConfig added in v1.0.21

type PyroscopeConfig struct {
	Enabled         bool     `mapstructure:"enabled"`
	ServerAddress   string   `mapstructure:"server_address"`
	ApplicationName string   `mapstructure:"application_name"`
	BasicAuthUser   string   `mapstructure:"basic_auth_user"`
	BasicAuthPass   string   `mapstructure:"basic_auth_password"`
	ProfileTypes    []string `mapstructure:"profile_types"`
	SampleRate      uint32   `mapstructure:"sample_rate" default:"100"`
	DisableGCRuns   bool     `mapstructure:"disable_gc_runs" default:"false"`
}

type S3Config added in v1.0.13

type S3Config struct {
	Enabled             bool         `mapstructure:"enabled" validate:"required"`
	Region              string       `mapstructure:"region" validate:"required"`
	InvoiceBucketConfig BucketConfig `mapstructure:"invoice" validate:"required"`
}

type SecretsConfig

type SecretsConfig struct {
	EncryptionKey string `mapstructure:"encryption_key" validate:"required"`
}

type SentryConfig

type SentryConfig struct {
	Enabled     bool    `mapstructure:"enabled"`
	DSN         string  `mapstructure:"dsn"`
	Environment string  `mapstructure:"environment"`
	SampleRate  float64 `mapstructure:"sample_rate" default:"1.0"`
}

type ServerConfig

type ServerConfig struct {
	Address string `mapstructure:"address" validate:"required"`
}

type SupabaseConfig

type SupabaseConfig struct {
	BaseURL    string `mapstructure:"base_url"`
	ServiceKey string `mapstructure:"service_key"`
}

type Svix added in v1.0.18

type Svix struct {
	Enabled   bool   `mapstructure:"enabled"`
	AuthToken string `mapstructure:"auth_token"`
	BaseURL   string `mapstructure:"base_url"`
}

type TemporalConfig

type TemporalConfig struct {
	Address    string `mapstructure:"address" validate:"required"`
	TaskQueue  string `mapstructure:"task_queue" validate:"required"`
	Namespace  string `mapstructure:"namespace" validate:"required"`
	APIKey     string `mapstructure:"api_key"`
	APIKeyName string `mapstructure:"api_key_name"`
	TLS        bool   `mapstructure:"tls"`
}

type TenantWebhookConfig

type TenantWebhookConfig struct {
	Endpoint       string            `mapstructure:"endpoint"`
	Headers        map[string]string `mapstructure:"headers"`
	Enabled        bool              `mapstructure:"enabled"`
	ExcludedEvents []string          `mapstructure:"excluded_events"`
}

TenantWebhookConfig represents webhook configuration for a specific tenant

type Webhook

type Webhook struct {
	Enabled         bool                           `mapstructure:"enabled"`
	Topic           string                         `mapstructure:"topic" default:"webhooks"`
	PubSub          types.PubSubType               `mapstructure:"pubsub" default:"kafka"`
	ConsumerGroup   string                         `mapstructure:"consumer_group" default:"webhook-consumer"`
	MaxRetries      int                            `mapstructure:"max_retries" default:"3"`
	InitialInterval time.Duration                  `mapstructure:"initial_interval" default:"1s"`
	MaxInterval     time.Duration                  `mapstructure:"max_interval" default:"10s"`
	Multiplier      float64                        `mapstructure:"multiplier" default:"2.0"`
	MaxElapsedTime  time.Duration                  `mapstructure:"max_elapsed_time" default:"2m"`
	Tenants         map[string]TenantWebhookConfig `mapstructure:"tenants"`
	Svix            Svix                           `mapstructure:"svix_config"`
}

Webhook represents the configuration for the webhook system

Jump to

Keyboard shortcuts

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