config

package
v1.1.59 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 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    string `mapstructure:"type" 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"`
	FlexpriceS3Exports         FlexpriceS3ExportsConfig         `mapstructure:"flexprice_s3_exports" validate:"omitempty"`
	Cache                      CacheConfig                      `validate:"required"`
	EventProcessing            EventProcessingConfig            `mapstructure:"event_processing" validate:"required"`
	EventProcessingLazy        EventProcessingLazyConfig        `mapstructure:"event_processing_lazy" validate:"required"`
	CostSheetUsageTracking     CostSheetUsageTrackingConfig     `mapstructure:"costsheet_usage_tracking" validate:"required"`
	CostSheetUsageTrackingLazy CostSheetUsageTrackingLazyConfig `mapstructure:"costsheet_usage_tracking_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"`
	RBAC                       RBACConfig                       `mapstructure:"rbac" validate:"omitempty"`
	OAuth                      OAuthConfig                      `mapstructure:"oauth" validate:"required"`
	WalletBalanceAlert         WalletBalanceAlertConfig         `mapstructure:"wallet_balance_alert" validate:"required"`
	CustomerPortal             CustomerPortalConfig             `mapstructure:"customer_portal" validate:"required"`
	Redis                      RedisConfig                      `mapstructure:"redis" 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 CostSheetUsageTrackingConfig added in v1.0.47

type CostSheetUsageTrackingConfig struct {
	Topic         string `mapstructure:"topic" default:"events"`
	RateLimit     int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup string `mapstructure:"consumer_group" default:"v1_costsheet_usage_tracking_service"`
}

type CostSheetUsageTrackingLazyConfig added in v1.0.47

type CostSheetUsageTrackingLazyConfig struct {
	Topic         string `mapstructure:"topic" default:"events_lazy"`
	RateLimit     int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup string `mapstructure:"consumer_group" default:"v1_costsheet_usage_tracking_service_lazy"`
}

type CustomerPortalConfig added in v1.0.50

type CustomerPortalConfig struct {
	URL               string `mapstructure:"url" validate:"required"`
	TokenTimeoutHours int    `mapstructure:"token_timeout_hours" validate:"required"`
}

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 FlexpriceS3ExportsConfig added in v1.0.59

type FlexpriceS3ExportsConfig struct {
	Bucket             string `mapstructure:"bucket" validate:"required"`
	Region             string `mapstructure:"region" validate:"required"`
	AWSAccessKeyID     string `mapstructure:"aws_access_key_id" validate:"required"`
	AWSSecretAccessKey string `mapstructure:"aws_secret_access_key" validate:"required"`
	AWSSessionToken    string `mapstructure:"aws_session_token,omitempty"`
}

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"`
	DBLevel types.LogLevel `mapstructure:"db_level" validate:"required"`

	// Fluentd configuration
	FluentdEnabled bool   `mapstructure:"fluentd_enabled" default:"false"`
	FluentdHost    string `mapstructure:"fluentd_host" validate:"omitempty"`
	FluentdPort    int    `mapstructure:"fluentd_port" validate:"omitempty"`
}

type OAuthConfig added in v1.0.47

type OAuthConfig struct {
	// Base redirect URI - provider-specific paths may be appended
	// Example: "https://admin-dev.flexprice.io/tools/integrations/oauth/callback"
	RedirectURI string `mapstructure:"redirect_uri" validate:"required,url"`
}

OAuthConfig holds generic OAuth configuration for multiple providers

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 RBACConfig added in v1.0.36

type RBACConfig struct {
	RolesConfigPath string `mapstructure:"roles_config_path" json:"roles_config_path"`
}

type RedisConfig added in v1.0.60

type RedisConfig struct {
	Host      string        `mapstructure:"host" default:"localhost"`
	Port      int           `mapstructure:"port" default:"6379"`
	Password  string        `mapstructure:"password" default:""`
	DB        int           `mapstructure:"db" default:"0"`
	UseTLS    bool          `mapstructure:"use_tls" default:"false"`
	PoolSize  int           `mapstructure:"pool_size" default:"10"`
	Timeout   time.Duration `mapstructure:"timeout" default:"5s"`
	KeyPrefix string        `mapstructure:"key_prefix" default:"flexprice"`
}

RedisConfig holds configuration for Redis

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 WalletBalanceAlertConfig added in v1.0.42

type WalletBalanceAlertConfig struct {
	// Rate limit in messages consumed per second
	Topic         string `mapstructure:"topic" default:"wallet_alert"`
	RateLimit     int64  `mapstructure:"rate_limit" default:"1"`
	ConsumerGroup string `mapstructure:"consumer_group" default:"v1_wallet_alert_service"`
}

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