Documentation
¶
Index ¶
- func DatabaseConnection(dbConfig DatabaseConfig) (*adapters.Database, error)
- func NewRateLimit(rateConfig *RateLimiterConfig) *redis_rate.Limit
- func QueueRedisConfig(redisConfig RedisConfig) *asynq.RedisClientOpt
- func RedisConnection(redisConfig RedisConfig) *adapters.Redis
- func SetupLogger(env string)
- type Config
- type DatabaseConfig
- type QueueWorkerConfig
- type RateLimiterConfig
- type RedisConfig
- type SchedulerConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseConnection ¶
func DatabaseConnection(dbConfig DatabaseConfig) (*adapters.Database, error)
DatabaseConnection establishes a connection to the MongoDB database.
func NewRateLimit ¶
func NewRateLimit(rateConfig *RateLimiterConfig) *redis_rate.Limit
NewRateLimit creates a rate limiter configuration.
func QueueRedisConfig ¶
func QueueRedisConfig(redisConfig RedisConfig) *asynq.RedisClientOpt
QueueRedisConfig returns Redis configuration for the task queue.
func RedisConnection ¶
func RedisConnection(redisConfig RedisConfig) *adapters.Redis
RedisConnection establishes a connection to the Redis database.
func SetupLogger ¶
func SetupLogger(env string)
SetupLogger configures the global logger based on the environment.
Types ¶
type Config ¶
type Config struct { Server ServerConfig `mapstructure:"server"` Database DatabaseConfig `mapstructure:"database"` JWT services.JWTConfig `mapstructure:"jwt"` Redis RedisConfig `mapstructure:"redis"` Env string `mapstructure:"env"` // Current application environment (e.g., development, production). Scheduler SchedulerConfig `mapstructure:"scheduler"` QueueWorker QueueWorkerConfig `mapstructure:"queue_worker"` Email notifications.EmailConfig `mapstructure:"email"` RateLimiter struct { App RateLimiterConfig `mapstructure:"app"` // Application-level rate limiter settings. } `mapstructure:"rate_limiter"` }
Config holds the complete application configuration.
func LoadConfig ¶
LoadConfig loads the application configuration from a YAML file or environment variables.
type DatabaseConfig ¶
DatabaseConfig holds the MongoDB connection details.
type QueueWorkerConfig ¶
type QueueWorkerConfig struct { Concurrency int `mapstructure:"concurrency"` // Number of concurrent workers. QueueName string `mapstructure:"queue_name"` // Name of the queue to process. EnabledForEnv []string `mapstructure:"enabled_for_env"` // Environments where the worker is enabled. }
QueueWorkerConfig holds the configuration for the queue worker.
type RateLimiterConfig ¶
type RateLimiterConfig struct { Rate int `mapstructure:"rate"` // Maximum requests per period. Burst int `mapstructure:"burst"` // Maximum burst capacity. Period time.Duration `mapstructure:"period"` // Time period for rate limiting. }
RateLimiterConfig defines the rate limiting settings.
type RedisConfig ¶
type RedisConfig struct { URL string `mapstructure:"url"` Password string `mapstructure:"password"` DB int `mapstructure:"db"` }
RedisConfig holds the Redis connection details.
type SchedulerConfig ¶
type SchedulerConfig struct { Interval time.Duration `mapstructure:"interval"` // Polling interval for reminders. ReminderDays []int `mapstructure:"reminder_days"` // Days before renewal to send reminders. EnabledForEnv []string `mapstructure:"enabled_for_env"` // Environments where the scheduler is enabled. }
SchedulerConfig holds the configuration for the subscription scheduler.
type ServerConfig ¶
type ServerConfig struct { Port int `mapstructure:"port"` TLS struct { Enabled bool `mapstructure:"enabled"` CertPath string `mapstructure:"cert_path"` KeyPath string `mapstructure:"key_path"` } `mapstructure:"tls"` }
ServerConfig holds the server configuration, including TLS settings.