From f410a5408e53ced8588a44732cb39cc652663075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D1=80=D0=B8=D0=B3=D0=BE=D1=80=D0=B8=D0=B9=20=D0=A1?= =?UTF-8?q?=D0=B0=D1=84=D1=80=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Mon, 27 Apr 2026 19:15:38 +0000 Subject: [PATCH] Delete internal/config/old_config.go --- internal/config/old_config.go | 124 ---------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 internal/config/old_config.go diff --git a/internal/config/old_config.go b/internal/config/old_config.go deleted file mode 100644 index d05ff51..0000000 --- a/internal/config/old_config.go +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2026 Safronov Grigorii - * - * Licensed under the CDDL, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * https://opensource.org/licenses/CDDL-1.0 - */ - -// Файл: internal/config/config.go -// Назначение: Загрузка и парсинг TOML-конфигурации, валидация параметров, -// предоставление доступа к настройкам кластера, хранилища и REPL. - -package config - -import ( - "github.com/BurntSushi/toml" -) - -type Config struct { - Cluster ClusterConfig `toml:"cluster"` - Storage StorageConfig `toml:"storage"` - Repl ReplConfig `toml:"repl"` - Log LogConfig `toml:"log"` - Replication ReplicationConfig `toml:"replication"` - Plugins PluginsConfig `toml:"plugins"` - Compression CompressionConfig `toml:"compression"` - WebUI WebUIConfig `toml:"webui"` -} - -type ClusterConfig struct { - Name string `toml:"name"` - NodeIP string `toml:"node_ip"` - NodePort int `toml:"node_port"` - RaftPort int `toml:"raft_port"` - RaftDataDir string `toml:"raft_data_dir"` - Bootstrap bool `toml:"bootstrap"` // Флаг бутстрапа кластера - Nodes []string `toml:"nodes"` // Список узлов кластера -} - -type StorageConfig struct { - PageSizeMB int `toml:"page_size_mb"` - MaxCollections int `toml:"max_collections"` - MaxDocumentsPerCollection int `toml:"max_documents_per_collection"` -} - -type ReplConfig struct { - PromptColor string `toml:"prompt_color"` - HistorySize int `toml:"history_size"` -} - -type LogConfig struct { - LogFile string `toml:"log_file"` - LogLevel string `toml:"log_level"` -} - -type ReplicationConfig struct { - Enabled bool `toml:"enabled"` - MasterMaster bool `toml:"master_master"` - SyncReplication bool `toml:"sync_replication"` - ReplicationTimeoutMs int `toml:"replication_timeout_ms"` -} - -type PluginsConfig struct { - Enabled bool `toml:"enabled"` - ScriptDir string `toml:"script_dir"` - AllowList []string `toml:"allow_list"` -} - -type CompressionConfig struct { - Enabled bool `toml:"enabled"` // Включено ли сжатие - Algorithm string `toml:"algorithm"` // Алгоритм сжатия (snappy, lz4, zstd) - Level int `toml:"level"` // Уровень сжатия (1-9, зависит от алгоритма) - MinSize int `toml:"min_size"` // Минимальный размер для сжатия (байт) -} - -type WebUIConfig struct { - Enabled bool `toml:"enabled"` // Включить веб-интерфейс - Port int `toml:"port"` // Порт для веб-интерфейса - Theme string `toml:"theme"` // Тема оформления (dark, light) -} - -func LoadConfig(path string) (*Config, error) { - var cfg Config - if _, err := toml.DecodeFile(path, &cfg); err != nil { - return nil, err - } - - // Установка значений по умолчанию, если не указаны - if cfg.Cluster.RaftPort == 0 { - cfg.Cluster.RaftPort = 9878 - } - if cfg.Cluster.RaftDataDir == "" { - cfg.Cluster.RaftDataDir = "raft_data" - } - if cfg.Replication.ReplicationTimeoutMs == 0 { - cfg.Replication.ReplicationTimeoutMs = 5000 - } - if cfg.Plugins.ScriptDir == "" { - cfg.Plugins.ScriptDir = "plugins" - } - - // Установка значений по умолчанию для сжатия - if cfg.Compression.Algorithm == "" { - cfg.Compression.Algorithm = "snappy" - } - if cfg.Compression.MinSize == 0 { - cfg.Compression.MinSize = 1024 // 1KB - сжимаем только документы больше 1KB - } - if cfg.Compression.Level == 0 { - cfg.Compression.Level = 3 // Средний уровень сжатия - } - - // Установка значений по умолчанию для WebUI - if cfg.WebUI.Port == 0 { - cfg.WebUI.Port = 8080 - } - if cfg.WebUI.Theme == "" { - cfg.WebUI.Theme = "dark" - } - - return &cfg, nil -}