Skip to content

Commit de23384

Browse files
author
ohotnikov.ivan
committed
eng translate
Signed-off-by: ohotnikov.ivan <[email protected]>
1 parent 9418a52 commit de23384

File tree

8 files changed

+241
-241
lines changed

8 files changed

+241
-241
lines changed

internal/pkg/ui/initwizard/cache.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
"time"
66
)
77

8-
// CacheEntry представляет запись в кэше
8+
// CacheEntry represents a cache entry
99
type CacheEntry struct {
1010
Value interface{}
1111
ExpiresAt time.Time
1212
CreatedAt time.Time
1313
}
1414

15-
// Cache представляет простой in-memory кэш с TTL
15+
// Cache represents a simple in-memory cache with TTL
1616
type Cache struct {
1717
data map[string]*CacheEntry
1818
mutex sync.RWMutex
@@ -22,15 +22,15 @@ type Cache struct {
2222
misses int64
2323
}
2424

25-
// NewCache создает новый экземпляр кэша
25+
// NewCache creates a new cache instance
2626
func NewCache(ttl time.Duration) *Cache {
2727
return &Cache{
2828
data: make(map[string]*CacheEntry),
2929
ttl: ttl,
3030
}
3131
}
3232

33-
// Get получает значение из кэша
33+
// Get retrieves a value from the cache
3434
func (c *Cache) Get(key string) (interface{}, bool) {
3535
c.mutex.RLock()
3636
entry, exists := c.data[key]
@@ -41,7 +41,7 @@ func (c *Cache) Get(key string) (interface{}, bool) {
4141
return nil, false
4242
}
4343

44-
// Проверяем TTL
44+
// Check TTL
4545
if time.Now().After(entry.ExpiresAt) {
4646
c.mutex.Lock()
4747
delete(c.data, key)
@@ -55,7 +55,7 @@ func (c *Cache) Get(key string) (interface{}, bool) {
5555
return entry.Value, true
5656
}
5757

58-
// Set устанавливает значение в кэш
58+
// Set sets a value in the cache
5959
func (c *Cache) Set(key string, value interface{}) {
6060
c.mutex.Lock()
6161
defer c.mutex.Unlock()
@@ -67,35 +67,35 @@ func (c *Cache) Set(key string, value interface{}) {
6767
}
6868
}
6969

70-
// Delete удаляет запись из кэша
70+
// Delete removes an entry from the cache
7171
func (c *Cache) Delete(key string) {
7272
c.mutex.Lock()
7373
defer c.mutex.Unlock()
7474
delete(c.data, key)
7575
}
7676

77-
// Clear очищает весь кэш
77+
// Clear clears the entire cache
7878
func (c *Cache) Clear() {
7979
c.mutex.Lock()
8080
defer c.mutex.Unlock()
8181
c.data = make(map[string]*CacheEntry)
8282
}
8383

84-
// Size возвращает размер кэша
84+
// Size returns the cache size
8585
func (c *Cache) Size() int {
8686
c.mutex.RLock()
8787
defer c.mutex.RUnlock()
8888
return len(c.data)
8989
}
9090

91-
// Stats возвращает статистику кэша
91+
// Stats returns cache statistics
9292
func (c *Cache) Stats() (hits, misses, evicted, size int64) {
9393
c.mutex.RLock()
9494
defer c.mutex.RUnlock()
9595
return c.hits, c.misses, c.evicted, int64(len(c.data))
9696
}
9797

98-
// Cleanup удаляет истекшие записи
98+
// Cleanup removes expired entries
9999
func (c *Cache) Cleanup() {
100100
c.mutex.Lock()
101101
defer c.mutex.Unlock()
@@ -109,7 +109,7 @@ func (c *Cache) Cleanup() {
109109
}
110110
}
111111

112-
// StartCleanup запускает автоматическую очистку кэша
112+
// StartCleanup starts automatic cache cleanup
113113
func (c *Cache) StartCleanup(interval time.Duration) {
114114
ticker := time.NewTicker(interval)
115115
go func() {
@@ -123,24 +123,24 @@ func (c *Cache) StartCleanup(interval time.Duration) {
123123
}()
124124
}
125125

126-
// NodeCache специализированный кэш для информации о нодах
126+
// NodeCache specialized cache for node information
127127
type NodeCache struct {
128128
cache *Cache
129129
nodeMutex sync.RWMutex
130-
nodes map[string]NodeInfo // Кэш последней информации о ноде
130+
nodes map[string]NodeInfo // Cache of the latest node information
131131
}
132132

133-
// NewNodeCache создает новый кэш нод
133+
// NewNodeCache creates a new node cache
134134
func NewNodeCache(ttl time.Duration) *NodeCache {
135135
return &NodeCache{
136136
cache: NewCache(ttl),
137137
nodes: make(map[string]NodeInfo),
138138
}
139139
}
140140

141-
// GetNodeInfo получает информацию о ноде из кэша
141+
// GetNodeInfo retrieves node information from the cache
142142
func (nc *NodeCache) GetNodeInfo(ip string) (NodeInfo, bool) {
143-
// Сначала проверяем кэш в памяти
143+
// First check the in-memory cache
144144
nc.nodeMutex.RLock()
145145
node, exists := nc.nodes[ip]
146146
nc.nodeMutex.RUnlock()
@@ -149,10 +149,10 @@ func (nc *NodeCache) GetNodeInfo(ip string) (NodeInfo, bool) {
149149
return node, true
150150
}
151151

152-
// Проверяем общий кэш
152+
// Check the general cache
153153
if cached, found := nc.cache.Get("node:" + ip); found {
154154
if nodeInfo, ok := cached.(NodeInfo); ok {
155-
// Сохраняем в локальный кэш
155+
// Save to local cache
156156
nc.nodeMutex.Lock()
157157
nc.nodes[ip] = nodeInfo
158158
nc.nodeMutex.Unlock()
@@ -163,7 +163,7 @@ func (nc *NodeCache) GetNodeInfo(ip string) (NodeInfo, bool) {
163163
return NodeInfo{}, false
164164
}
165165

166-
// SetNodeInfo сохраняет информацию о ноде в кэш
166+
// SetNodeInfo saves node information to the cache
167167
func (nc *NodeCache) SetNodeInfo(ip string, node NodeInfo) {
168168
nc.nodeMutex.Lock()
169169
nc.nodes[ip] = node
@@ -172,7 +172,7 @@ func (nc *NodeCache) SetNodeInfo(ip string, node NodeInfo) {
172172
nc.cache.Set("node:"+ip, node)
173173
}
174174

175-
// InvalidateNodeInfo удаляет информацию о ноде из кэша
175+
// InvalidateNodeInfo removes node information from the cache
176176
func (nc *NodeCache) InvalidateNodeInfo(ip string) {
177177
nc.nodeMutex.Lock()
178178
delete(nc.nodes, ip)
@@ -181,19 +181,19 @@ func (nc *NodeCache) InvalidateNodeInfo(ip string) {
181181
nc.cache.Delete("node:" + ip)
182182
}
183183

184-
// HardwareCache специализированный кэш для информации об оборудовании
184+
// HardwareCache specialized cache for hardware information
185185
type HardwareCache struct {
186186
cache *Cache
187187
}
188188

189-
// NewHardwareCache создает новый кэш оборудования
189+
// NewHardwareCache creates a new hardware cache
190190
func NewHardwareCache(ttl time.Duration) *HardwareCache {
191191
return &HardwareCache{
192192
cache: NewCache(ttl),
193193
}
194194
}
195195

196-
// GetHardwareInfo получает информацию об оборудовании из кэша
196+
// GetHardwareInfo retrieves hardware information from the cache
197197
func (hc *HardwareCache) GetHardwareInfo(ip string) (Hardware, bool) {
198198
if cached, found := hc.cache.Get("hardware:" + ip); found {
199199
if hardware, ok := cached.(Hardware); ok {
@@ -203,43 +203,43 @@ func (hc *HardwareCache) GetHardwareInfo(ip string) (Hardware, bool) {
203203
return Hardware{}, false
204204
}
205205

206-
// SetHardwareInfo сохраняет информацию об оборудовании в кэш
206+
// SetHardwareInfo saves hardware information to the cache
207207
func (hc *HardwareCache) SetHardwareInfo(ip string, hardware Hardware) {
208208
hc.cache.Set("hardware:"+ip, hardware)
209209
}
210210

211-
// InvalidateHardwareInfo удаляет информацию об оборудовании из кэша
211+
// InvalidateHardwareInfo removes hardware information from the cache
212212
func (hc *HardwareCache) InvalidateHardwareInfo(ip string) {
213213
hc.cache.Delete("hardware:" + ip)
214214
}
215215

216-
// ConfigCache кэш для конфигурационных файлов
216+
// ConfigCache cache for configuration files
217217
type ConfigCache struct {
218218
cache *Cache
219219
}
220220

221-
// NewConfigCache создает новый кэш конфигураций
221+
// NewConfigCache creates a new configuration cache
222222
func NewConfigCache(ttl time.Duration) *ConfigCache {
223223
return &ConfigCache{
224224
cache: NewCache(ttl),
225225
}
226226
}
227227

228-
// GetConfig получает конфигурацию из кэша
228+
// GetConfig retrieves configuration from the cache
229229
func (cc *ConfigCache) GetConfig(clusterName, configType string) (interface{}, bool) {
230230
key := clusterName + ":" + configType
231231
return cc.cache.Get(key)
232232
}
233233

234-
// SetConfig сохраняет конфигурацию в кэш
234+
// SetConfig saves configuration to the cache
235235
func (cc *ConfigCache) SetConfig(clusterName, configType string, config interface{}) {
236236
key := clusterName + ":" + configType
237237
cc.cache.Set(key, config)
238238
}
239239

240-
// InvalidateClusterConfig удаляет все конфигурации кластера из кэша
240+
// InvalidateClusterConfig removes all cluster configurations from the cache
241241
func (cc *ConfigCache) InvalidateClusterConfig(clusterName string) {
242-
// Упрощенная реализация - в реальном приложении можно использовать префиксы
242+
// Simplified implementation - in a real application, prefixes can be used
243243
// для более эффективного удаления
244244
cc.cache.Clear()
245245
}

internal/pkg/ui/initwizard/interfaces.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/siderolabs/talos/pkg/machinery/config/generate/secrets"
88
)
99

10-
// Wizard интерфейс основного компонента мастера инициализации
10+
// Wizard interface of the main initialization wizard component
1111
type Wizard interface {
1212
Run() error
1313
getData() *InitData
@@ -17,7 +17,7 @@ type Wizard interface {
1717
GetScanner() NetworkScanner
1818
}
1919

20-
// Validator интерфейс компонента валидации
20+
// Validator interface of the validation component
2121
type Validator interface {
2222
ValidateNetworkCIDR(cidr string) error
2323
ValidateClusterName(name string) error
@@ -32,7 +32,7 @@ type Validator interface {
3232
ValidateAPIServerURL(url string) error
3333
}
3434

35-
// DataProcessor интерфейс компонента обработки данных
35+
// DataProcessor interface of the data processing component
3636
type DataProcessor interface {
3737
FilterAndSortNodes(nodes []NodeInfo) []NodeInfo
3838
ExtractHardwareInfo(ip string) (Hardware, error)
@@ -41,7 +41,7 @@ type DataProcessor interface {
4141
RemoveDuplicatesByMAC(nodes []NodeInfo) []NodeInfo
4242
}
4343

44-
// Generator интерфейс компонента генерации конфигураций
44+
// Generator interface of the configuration generation component
4545
type Generator interface {
4646
GenerateChartYAML(clusterName, preset string) (ChartYAML, error)
4747
GenerateValuesYAML(data *InitData) (ValuesYAML, error)
@@ -59,7 +59,7 @@ type Generator interface {
5959
SaveSecretsBundle(bundle *secrets.Bundle) error
6060
}
6161

62-
// NetworkScanner интерфейс компонента сканирования сети
62+
// NetworkScanner interface of the network scanning component
6363
type NetworkScanner interface {
6464
ScanNetwork(ctx context.Context, cidr string) ([]NodeInfo, error)
6565
ScanNetworkWithProgress(ctx context.Context, cidr string, progressFunc func(int)) ([]NodeInfo, error)
@@ -69,7 +69,7 @@ type NetworkScanner interface {
6969
ParallelScan(ctx context.Context, ips []string) ([]NodeInfo, error)
7070
}
7171

72-
// Presenter интерфейс компонента пользовательского интерфейса
72+
// Presenter interface of the user interface component
7373
type Presenter interface {
7474
ShowStep1Form(data *InitData) *tview.Form
7575
ShowGenericStep2(data *InitData)
@@ -87,7 +87,7 @@ type Presenter interface {
8787
ShowFirstNodeConfig(data *InitData)
8888
}
8989

90-
// UIHelper интерфейс вспомогательных функций UI
90+
// UIHelper interface of UI helper functions
9191
type UIHelper interface {
9292
CreateButton(text string, handler func()) *tview.Button
9393
CreateInputField(label, initialText string, fieldWidth int, validator func(string), changed func(string)) *tview.InputField

0 commit comments

Comments
 (0)