mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(server): implement management endpoints and redis sync
Enable full resource management via API and support data plane synchronization. - Add CRUD handlers for Providers, Models, and Keys using DTOs - Implement LogWriter service for asynchronous, batched audit logging - Update SyncService to snapshot full configuration state to Redis - Register new API routes and initialize background services - Add configuration options for logging performance tuning
This commit is contained in:
@@ -3,12 +3,14 @@ package config
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
Postgres PostgresConfig
|
||||
Redis RedisConfig
|
||||
Log LogConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -25,6 +27,12 @@ type RedisConfig struct {
|
||||
DB int
|
||||
}
|
||||
|
||||
type LogConfig struct {
|
||||
BatchSize int
|
||||
FlushInterval time.Duration
|
||||
QueueCapacity int
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
return &Config{
|
||||
Server: ServerConfig{
|
||||
@@ -38,6 +46,11 @@ func Load() (*Config, error) {
|
||||
Password: getEnv("EZ_REDIS_PASSWORD", ""),
|
||||
DB: getEnvInt("EZ_REDIS_DB", 0),
|
||||
},
|
||||
Log: LogConfig{
|
||||
BatchSize: getEnvInt("EZ_LOG_BATCH_SIZE", 10),
|
||||
FlushInterval: getEnvDuration("EZ_LOG_FLUSH_MS", 1000),
|
||||
QueueCapacity: getEnvInt("EZ_LOG_QUEUE", 10000),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -56,3 +69,12 @@ func getEnvInt(key string, fallback int) int {
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func getEnvDuration(key string, fallbackMs int) time.Duration {
|
||||
if value, ok := os.LookupEnv(key); ok {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
return time.Duration(i) * time.Millisecond
|
||||
}
|
||||
}
|
||||
return time.Duration(fallbackMs) * time.Millisecond
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user