@@ -965,10 +965,10 @@ func (client *NginxClient) getWithContext(ctx context.Context, path string, data
965
965
}
966
966
967
967
func (client * NginxClient ) post (path string , input interface {}) error {
968
- return client .postWithConext (context .Background (), path , input )
968
+ return client .postWithContext (context .Background (), path , input )
969
969
}
970
970
971
- func (client * NginxClient ) postWithConext (ctx context.Context , path string , input interface {}) error {
971
+ func (client * NginxClient ) postWithContext (ctx context.Context , path string , input interface {}) error {
972
972
ctx , cancel := context .WithTimeout (ctx , client .ctxTimeout )
973
973
defer cancel ()
974
974
@@ -1259,156 +1259,183 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1259
1259
stats := defaultStats ()
1260
1260
// Collecting initial stats
1261
1261
initialGroup .Go (func () error {
1262
- mu .Lock ()
1263
1262
endpoints , err := client .GetAvailableEndpointsWithContext (initialCtx )
1264
- mu .Unlock ()
1265
1263
if err != nil {
1266
1264
return fmt .Errorf ("failed to get available Endpoints: %w" , err )
1267
1265
}
1266
+
1267
+ mu .Lock ()
1268
1268
stats .endpoints = endpoints
1269
+ mu .Unlock ()
1269
1270
return nil
1270
1271
})
1271
1272
1272
1273
initialGroup .Go (func () error {
1273
- mu .Lock ()
1274
1274
nginxInfo , err := client .GetNginxInfoWithContext (initialCtx )
1275
- mu .Unlock ()
1276
1275
if err != nil {
1277
1276
return fmt .Errorf ("failed to get NGINX info: %w" , err )
1278
1277
}
1278
+
1279
+ mu .Lock ()
1279
1280
stats .NginxInfo = * nginxInfo
1281
+ mu .Unlock ()
1282
+
1280
1283
return nil
1281
1284
})
1282
1285
1283
1286
initialGroup .Go (func () error {
1284
- mu .Lock ()
1285
1287
caches , err := client .GetCachesWithContext (initialCtx )
1286
- mu .Unlock ()
1287
1288
if err != nil {
1288
1289
return fmt .Errorf ("failed to get Caches: %w" , err )
1289
1290
}
1291
+
1292
+ mu .Lock ()
1290
1293
stats .Caches = * caches
1294
+ mu .Unlock ()
1295
+
1291
1296
return nil
1292
1297
})
1293
1298
1294
1299
initialGroup .Go (func () error {
1295
- mu .Lock ()
1296
1300
processes , err := client .GetProcessesWithContext (initialCtx )
1297
- mu .Unlock ()
1298
1301
if err != nil {
1299
1302
return fmt .Errorf ("failed to get Process information: %w" , err )
1300
1303
}
1304
+
1305
+ mu .Lock ()
1301
1306
stats .Processes = * processes
1307
+ mu .Unlock ()
1308
+
1302
1309
return nil
1303
1310
})
1304
1311
1305
1312
initialGroup .Go (func () error {
1306
- mu .Lock ()
1307
1313
slabs , err := client .GetSlabsWithContext (initialCtx )
1308
- mu .Unlock ()
1309
1314
if err != nil {
1310
1315
return fmt .Errorf ("failed to get Slabs: %w" , err )
1311
1316
}
1317
+
1318
+ mu .Lock ()
1312
1319
stats .Slabs = * slabs
1320
+ mu .Unlock ()
1321
+
1313
1322
return nil
1314
1323
})
1315
1324
1316
1325
initialGroup .Go (func () error {
1317
- mu .Lock ()
1318
1326
httpRequests , err := client .GetHTTPRequestsWithContext (initialCtx )
1319
- mu .Unlock ()
1320
1327
if err != nil {
1321
1328
return fmt .Errorf ("failed to get HTTP Requests: %w" , err )
1322
1329
}
1330
+
1331
+ mu .Lock ()
1323
1332
stats .HTTPRequests = * httpRequests
1333
+ mu .Unlock ()
1334
+
1324
1335
return nil
1325
1336
})
1326
1337
1327
1338
initialGroup .Go (func () error {
1328
- mu .Lock ()
1329
1339
ssl , err := client .GetSSLWithContext (initialCtx )
1330
- mu .Unlock ()
1331
1340
if err != nil {
1332
1341
return fmt .Errorf ("failed to get SSL: %w" , err )
1333
1342
}
1343
+
1344
+ mu .Lock ()
1334
1345
stats .SSL = * ssl
1346
+ mu .Unlock ()
1347
+
1335
1348
return nil
1336
1349
})
1337
1350
1338
1351
initialGroup .Go (func () error {
1339
- mu .Lock ()
1340
1352
serverZones , err := client .GetServerZonesWithContext (initialCtx )
1341
- mu .Unlock ()
1342
1353
if err != nil {
1343
1354
return fmt .Errorf ("failed to get Server Zones: %w" , err )
1344
1355
}
1356
+
1357
+ mu .Lock ()
1345
1358
stats .ServerZones = * serverZones
1359
+ mu .Unlock ()
1360
+
1346
1361
return nil
1347
1362
})
1348
1363
1349
1364
initialGroup .Go (func () error {
1350
- mu .Lock ()
1351
1365
upstreams , err := client .GetUpstreamsWithContext (initialCtx )
1352
- mu .Unlock ()
1353
1366
if err != nil {
1354
1367
return fmt .Errorf ("failed to get Upstreams: %w" , err )
1355
1368
}
1369
+
1370
+ mu .Lock ()
1356
1371
stats .Upstreams = * upstreams
1372
+ mu .Unlock ()
1373
+
1357
1374
return nil
1358
1375
})
1359
1376
1360
1377
initialGroup .Go (func () error {
1361
- mu .Lock ()
1362
1378
locationZones , err := client .GetLocationZonesWithContext (initialCtx )
1363
- mu .Unlock ()
1364
1379
if err != nil {
1365
1380
return fmt .Errorf ("failed to get Location Zones: %w" , err )
1366
1381
}
1382
+
1383
+ mu .Lock ()
1367
1384
stats .LocationZones = * locationZones
1385
+ mu .Unlock ()
1386
+
1368
1387
return nil
1369
1388
})
1370
1389
1371
1390
initialGroup .Go (func () error {
1372
- mu .Lock ()
1373
1391
resolvers , err := client .GetResolversWithContext (initialCtx )
1374
- mu .Unlock ()
1375
1392
if err != nil {
1376
1393
return fmt .Errorf ("failed to get Resolvers: %w" , err )
1377
1394
}
1395
+
1396
+ mu .Lock ()
1378
1397
stats .Resolvers = * resolvers
1398
+ mu .Unlock ()
1399
+
1379
1400
return nil
1380
1401
})
1381
1402
1382
1403
initialGroup .Go (func () error {
1383
- mu .Lock ()
1384
1404
httpLimitRequests , err := client .GetHTTPLimitReqsWithContext (initialCtx )
1385
- mu .Unlock ()
1386
1405
if err != nil {
1387
1406
return fmt .Errorf ("failed to get HTTPLimitRequests: %w" , err )
1388
1407
}
1408
+
1409
+ mu .Lock ()
1389
1410
stats .HTTPLimitRequests = * httpLimitRequests
1411
+ mu .Unlock ()
1412
+
1390
1413
return nil
1391
1414
})
1392
1415
1393
1416
initialGroup .Go (func () error {
1394
- mu .Lock ()
1395
1417
httpLimitConnections , err := client .GetHTTPConnectionsLimitWithContext (initialCtx )
1396
- mu .Unlock ()
1397
1418
if err != nil {
1398
1419
return fmt .Errorf ("failed to get HTTPLimitConnections: %w" , err )
1399
1420
}
1421
+
1422
+ mu .Lock ()
1400
1423
stats .HTTPLimitConnections = * httpLimitConnections
1424
+ mu .Unlock ()
1425
+
1401
1426
return nil
1402
1427
})
1403
1428
1404
1429
initialGroup .Go (func () error {
1405
- mu .Lock ()
1406
1430
workers , err := client .GetWorkersWithContext (initialCtx )
1407
- mu .Unlock ()
1408
1431
if err != nil {
1409
1432
return fmt .Errorf ("failed to get Workers: %w" , err )
1410
1433
}
1434
+
1435
+ mu .Lock ()
1411
1436
stats .Workers = workers
1437
+ mu .Unlock ()
1438
+
1412
1439
return nil
1413
1440
})
1414
1441
@@ -1421,13 +1448,15 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1421
1448
availableStreamGroup , asgCtx := errgroup .WithContext (ctx )
1422
1449
1423
1450
availableStreamGroup .Go (func () error {
1424
- mu .Lock ()
1425
1451
streamEndpoints , err := client .GetAvailableStreamEndpointsWithContext (asgCtx )
1426
- mu .Unlock ()
1427
1452
if err != nil {
1428
1453
return fmt .Errorf ("failed to get available Stream Endpoints: %w" , err )
1429
1454
}
1455
+
1456
+ mu .Lock ()
1430
1457
stats .streamEndpoints = streamEndpoints
1458
+ mu .Unlock ()
1459
+
1431
1460
return nil
1432
1461
})
1433
1462
@@ -1443,9 +1472,11 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1443
1472
if err != nil {
1444
1473
return fmt .Errorf ("failed to get streamServerZones: %w" , err )
1445
1474
}
1475
+
1446
1476
mu .Lock ()
1447
1477
stats .StreamServerZones = * streamServerZones
1448
1478
mu .Unlock ()
1479
+
1449
1480
return nil
1450
1481
})
1451
1482
}
@@ -1456,6 +1487,7 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1456
1487
if err != nil {
1457
1488
return fmt .Errorf ("failed to get StreamUpstreams: %w" , err )
1458
1489
}
1490
+
1459
1491
mu .Lock ()
1460
1492
stats .StreamUpstreams = * streamUpstreams
1461
1493
mu .Unlock ()
@@ -1470,9 +1502,11 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1470
1502
if err != nil {
1471
1503
return fmt .Errorf ("failed to get StreamLimitConnections: %w" , err )
1472
1504
}
1505
+
1473
1506
mu .Lock ()
1474
1507
stats .StreamLimitConnections = * streamConnectionsLimit
1475
1508
mu .Unlock ()
1509
+
1476
1510
return nil
1477
1511
})
1478
1512
@@ -1481,9 +1515,11 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1481
1515
if err != nil {
1482
1516
return fmt .Errorf ("failed to get StreamZoneSync: %w" , err )
1483
1517
}
1518
+
1484
1519
mu .Lock ()
1485
1520
stats .StreamZoneSync = streamZoneSync
1486
1521
mu .Unlock ()
1522
+
1487
1523
return nil
1488
1524
})
1489
1525
}
@@ -1502,9 +1538,11 @@ func (client *NginxClient) GetStatsWithContext(ctx context.Context) (*Stats, err
1502
1538
if err != nil {
1503
1539
return fmt .Errorf ("failed to get connections: %w" , err )
1504
1540
}
1541
+
1505
1542
mu .Lock ()
1506
1543
stats .Connections = * connections
1507
1544
mu .Unlock ()
1545
+
1508
1546
return nil
1509
1547
})
1510
1548
0 commit comments