70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
fwconfig "repository.promas.id/prana/go-dw-framework/config"
|
|
)
|
|
|
|
type Config struct {
|
|
DB DBConfig
|
|
Sopiga SopigaConfig
|
|
Worker WorkerConfig
|
|
Webhook WebhookConfig
|
|
}
|
|
|
|
type DBConfig struct {
|
|
DSN string
|
|
MaxConns int32
|
|
MinConns int32
|
|
MaxConnLifetime time.Duration
|
|
MaxConnIdleTime time.Duration
|
|
}
|
|
|
|
type SopigaConfig struct {
|
|
BaseURL string
|
|
Token string
|
|
}
|
|
|
|
type WorkerConfig struct {
|
|
CheckInterval time.Duration
|
|
BatchSize int
|
|
MaxRetries int
|
|
RetryDelay time.Duration
|
|
SyncCheckInterval time.Duration
|
|
SyncBatchSize int
|
|
}
|
|
|
|
type WebhookConfig struct {
|
|
Port string
|
|
Secret string
|
|
}
|
|
|
|
func LoadConfig() *Config {
|
|
return &Config{
|
|
DB: DBConfig{
|
|
DSN: fwconfig.GetString("DATABASE_DSN", ""),
|
|
MaxConns: int32(fwconfig.GetInt("DB_MAX_CONNS", 25)),
|
|
MinConns: int32(fwconfig.GetInt("DB_MIN_CONNS", 5)),
|
|
MaxConnLifetime: 15 * time.Minute,
|
|
MaxConnIdleTime: 5 * time.Minute,
|
|
},
|
|
Sopiga: SopigaConfig{
|
|
BaseURL: fwconfig.GetString("SOPIGA_BASE_URL", "https://omnix.promas.site"),
|
|
Token: fwconfig.GetString("SOPIGA_TOKEN", ""),
|
|
},
|
|
Worker: WorkerConfig{
|
|
CheckInterval: time.Duration(fwconfig.GetInt("WORKER_CHECK_INTERVAL_SEC", 30)) * time.Second,
|
|
BatchSize: fwconfig.GetInt("WORKER_BATCH_SIZE", 100),
|
|
MaxRetries: fwconfig.GetInt("WORKER_MAX_RETRIES", 3),
|
|
RetryDelay: time.Second,
|
|
SyncCheckInterval: time.Duration(fwconfig.GetInt("WORKER_SYNC_INTERVAL_SEC", 300)) * time.Second,
|
|
SyncBatchSize: fwconfig.GetInt("WORKER_SYNC_BATCH_SIZE", 100),
|
|
},
|
|
Webhook: WebhookConfig{
|
|
Port: fwconfig.GetString("WEBHOOK_PORT", "8081"),
|
|
Secret: fwconfig.GetString("WEBHOOK_SECRET", ""),
|
|
},
|
|
}
|
|
}
|