Skip to content

Commit 0403bac

Browse files
committed
fix line end formatting
1 parent 2c6c3d7 commit 0403bac

File tree

10 files changed

+199
-200
lines changed

10 files changed

+199
-200
lines changed

packages/indexer-agent/src/agent-optimized.ts

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

packages/indexer-agent/src/performance-config.ts

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ export interface PerformanceConfig {
99
deploymentConcurrency: number
1010
networkQueryConcurrency: number
1111
batchSize: number
12-
12+
1313
// Cache settings
1414
enableCache: boolean
1515
cacheTTL: number
1616
cacheMaxSize: number
1717
cacheCleanupInterval: number
18-
18+
1919
// Circuit breaker settings
2020
enableCircuitBreaker: boolean
2121
circuitBreakerFailureThreshold: number
2222
circuitBreakerResetTimeout: number
2323
circuitBreakerHalfOpenMaxAttempts: number
24-
24+
2525
// Priority queue settings
2626
enablePriorityQueue: boolean
2727
priorityQueueSignalThreshold: string
2828
priorityQueueStakeThreshold: string
29-
29+
3030
// Network settings
3131
enableParallelNetworkQueries: boolean
3232
networkQueryBatchSize: number
3333
networkQueryTimeout: number
34-
34+
3535
// Retry settings
3636
maxRetryAttempts: number
3737
retryDelay: number
3838
retryBackoffMultiplier: number
39-
39+
4040
// Monitoring settings
4141
enableMetrics: boolean
4242
metricsInterval: number
@@ -49,34 +49,34 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
4949
deploymentConcurrency: 15,
5050
networkQueryConcurrency: 10,
5151
batchSize: 10,
52-
52+
5353
// Cache settings
5454
enableCache: true,
5555
cacheTTL: 30000, // 30 seconds
5656
cacheMaxSize: 2000,
5757
cacheCleanupInterval: 60000, // 1 minute
58-
58+
5959
// Circuit breaker settings
6060
enableCircuitBreaker: true,
6161
circuitBreakerFailureThreshold: 5,
6262
circuitBreakerResetTimeout: 60000, // 1 minute
6363
circuitBreakerHalfOpenMaxAttempts: 3,
64-
64+
6565
// Priority queue settings
6666
enablePriorityQueue: true,
6767
priorityQueueSignalThreshold: '1000000000000000000000', // 1000 GRT
6868
priorityQueueStakeThreshold: '10000000000000000000000', // 10000 GRT
69-
69+
7070
// Network settings
7171
enableParallelNetworkQueries: true,
7272
networkQueryBatchSize: 50,
7373
networkQueryTimeout: 30000, // 30 seconds
74-
74+
7575
// Retry settings
7676
maxRetryAttempts: 3,
7777
retryDelay: 1000, // 1 second
7878
retryBackoffMultiplier: 2,
79-
79+
8080
// Monitoring settings
8181
enableMetrics: true,
8282
metricsInterval: 60000, // 1 minute
@@ -88,96 +88,96 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
8888
*/
8989
export function loadPerformanceConfig(): PerformanceConfig {
9090
const config = { ...DEFAULT_PERFORMANCE_CONFIG }
91-
91+
9292
// Override with environment variables if present
9393
if (process.env.ALLOCATION_CONCURRENCY) {
9494
config.allocationConcurrency = parseInt(process.env.ALLOCATION_CONCURRENCY)
9595
}
96-
96+
9797
if (process.env.DEPLOYMENT_CONCURRENCY) {
9898
config.deploymentConcurrency = parseInt(process.env.DEPLOYMENT_CONCURRENCY)
9999
}
100-
100+
101101
if (process.env.NETWORK_QUERY_CONCURRENCY) {
102102
config.networkQueryConcurrency = parseInt(process.env.NETWORK_QUERY_CONCURRENCY)
103103
}
104-
104+
105105
if (process.env.BATCH_SIZE) {
106106
config.batchSize = parseInt(process.env.BATCH_SIZE)
107107
}
108-
108+
109109
if (process.env.ENABLE_CACHE !== undefined) {
110110
config.enableCache = process.env.ENABLE_CACHE !== 'false'
111111
}
112-
112+
113113
if (process.env.CACHE_TTL) {
114114
config.cacheTTL = parseInt(process.env.CACHE_TTL)
115115
}
116-
116+
117117
if (process.env.CACHE_MAX_SIZE) {
118118
config.cacheMaxSize = parseInt(process.env.CACHE_MAX_SIZE)
119119
}
120-
120+
121121
if (process.env.ENABLE_CIRCUIT_BREAKER !== undefined) {
122122
config.enableCircuitBreaker = process.env.ENABLE_CIRCUIT_BREAKER !== 'false'
123123
}
124-
124+
125125
if (process.env.CIRCUIT_BREAKER_FAILURE_THRESHOLD) {
126126
config.circuitBreakerFailureThreshold = parseInt(process.env.CIRCUIT_BREAKER_FAILURE_THRESHOLD)
127127
}
128-
128+
129129
if (process.env.CIRCUIT_BREAKER_RESET_TIMEOUT) {
130130
config.circuitBreakerResetTimeout = parseInt(process.env.CIRCUIT_BREAKER_RESET_TIMEOUT)
131131
}
132-
132+
133133
if (process.env.ENABLE_PRIORITY_QUEUE !== undefined) {
134134
config.enablePriorityQueue = process.env.ENABLE_PRIORITY_QUEUE !== 'false'
135135
}
136-
136+
137137
if (process.env.PRIORITY_QUEUE_SIGNAL_THRESHOLD) {
138138
config.priorityQueueSignalThreshold = process.env.PRIORITY_QUEUE_SIGNAL_THRESHOLD
139139
}
140-
140+
141141
if (process.env.PRIORITY_QUEUE_STAKE_THRESHOLD) {
142142
config.priorityQueueStakeThreshold = process.env.PRIORITY_QUEUE_STAKE_THRESHOLD
143143
}
144-
144+
145145
if (process.env.ENABLE_PARALLEL_NETWORK_QUERIES !== undefined) {
146146
config.enableParallelNetworkQueries = process.env.ENABLE_PARALLEL_NETWORK_QUERIES !== 'false'
147147
}
148-
148+
149149
if (process.env.NETWORK_QUERY_BATCH_SIZE) {
150150
config.networkQueryBatchSize = parseInt(process.env.NETWORK_QUERY_BATCH_SIZE)
151151
}
152-
152+
153153
if (process.env.NETWORK_QUERY_TIMEOUT) {
154154
config.networkQueryTimeout = parseInt(process.env.NETWORK_QUERY_TIMEOUT)
155155
}
156-
156+
157157
if (process.env.MAX_RETRY_ATTEMPTS) {
158158
config.maxRetryAttempts = parseInt(process.env.MAX_RETRY_ATTEMPTS)
159159
}
160-
160+
161161
if (process.env.RETRY_DELAY) {
162162
config.retryDelay = parseInt(process.env.RETRY_DELAY)
163163
}
164-
164+
165165
if (process.env.RETRY_BACKOFF_MULTIPLIER) {
166166
config.retryBackoffMultiplier = parseFloat(process.env.RETRY_BACKOFF_MULTIPLIER)
167167
}
168-
168+
169169
if (process.env.ENABLE_METRICS !== undefined) {
170170
config.enableMetrics = process.env.ENABLE_METRICS !== 'false'
171171
}
172-
172+
173173
if (process.env.METRICS_INTERVAL) {
174174
config.metricsInterval = parseInt(process.env.METRICS_INTERVAL)
175175
}
176-
176+
177177
if (process.env.ENABLE_DETAILED_LOGGING !== undefined) {
178178
config.enableDetailedLogging = process.env.ENABLE_DETAILED_LOGGING === 'true'
179179
}
180-
180+
181181
return config
182182
}
183183

@@ -188,27 +188,27 @@ export function validatePerformanceConfig(config: PerformanceConfig): void {
188188
if (config.allocationConcurrency < 1 || config.allocationConcurrency > 100) {
189189
throw new Error('allocationConcurrency must be between 1 and 100')
190190
}
191-
191+
192192
if (config.deploymentConcurrency < 1 || config.deploymentConcurrency > 50) {
193193
throw new Error('deploymentConcurrency must be between 1 and 50')
194194
}
195-
195+
196196
if (config.batchSize < 1 || config.batchSize > 100) {
197197
throw new Error('batchSize must be between 1 and 100')
198198
}
199-
199+
200200
if (config.cacheTTL < 1000 || config.cacheTTL > 300000) {
201201
throw new Error('cacheTTL must be between 1000ms and 300000ms (5 minutes)')
202202
}
203-
203+
204204
if (config.cacheMaxSize < 100 || config.cacheMaxSize > 10000) {
205205
throw new Error('cacheMaxSize must be between 100 and 10000')
206206
}
207-
207+
208208
if (config.circuitBreakerFailureThreshold < 1 || config.circuitBreakerFailureThreshold > 20) {
209209
throw new Error('circuitBreakerFailureThreshold must be between 1 and 20')
210210
}
211-
211+
212212
if (config.maxRetryAttempts < 0 || config.maxRetryAttempts > 10) {
213213
throw new Error('maxRetryAttempts must be between 0 and 10')
214214
}
@@ -219,11 +219,11 @@ export function validatePerformanceConfig(config: PerformanceConfig): void {
219219
*/
220220
export function getOptimizedConfig(): PerformanceConfig {
221221
const config = loadPerformanceConfig()
222-
222+
223223
// Adjust based on available system resources
224224
const cpuCount = require('os').cpus().length
225225
const totalMemory = require('os').totalmem()
226-
226+
227227
// Adjust concurrency based on CPU cores
228228
if (cpuCount >= 8) {
229229
config.allocationConcurrency = Math.min(30, config.allocationConcurrency * 1.5)
@@ -232,14 +232,14 @@ export function getOptimizedConfig(): PerformanceConfig {
232232
config.allocationConcurrency = Math.max(5, config.allocationConcurrency * 0.5)
233233
config.deploymentConcurrency = Math.max(5, config.deploymentConcurrency * 0.5)
234234
}
235-
235+
236236
// Adjust cache size based on available memory
237237
const memoryGB = totalMemory / (1024 * 1024 * 1024)
238238
if (memoryGB >= 16) {
239239
config.cacheMaxSize = Math.min(5000, config.cacheMaxSize * 2)
240240
} else if (memoryGB <= 4) {
241241
config.cacheMaxSize = Math.max(500, config.cacheMaxSize * 0.5)
242242
}
243-
243+
244244
return config
245-
}
245+
}

0 commit comments

Comments
 (0)