mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 21:04:18 +02:00
satisfy full linter
This commit is contained in:
@@ -38,13 +38,15 @@ type clusterReachable struct {
|
||||
}
|
||||
|
||||
func ClusterList(conf *cfg.Config) error {
|
||||
var mu sync.Mutex
|
||||
var wg sync.WaitGroup
|
||||
var (
|
||||
mu sync.Mutex
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
reachable := make(map[string]clusterReachable, len(conf.Clusters))
|
||||
|
||||
// check endpoints in parallel to speed things up
|
||||
for name, cluster := range conf.Clusters {
|
||||
|
||||
wg.Go(func() {
|
||||
online, err := cluster.IsReachable()
|
||||
|
||||
@@ -119,26 +121,26 @@ func getClusterStatus(conf *cfg.Config) (*apiResponse, error) {
|
||||
|
||||
var err error
|
||||
|
||||
for i := 0; i < gocount; i++ {
|
||||
r := <-responses
|
||||
for range gocount {
|
||||
res := <-responses
|
||||
|
||||
err = errors.Join(err, r.error)
|
||||
err = errors.Join(err, res.error)
|
||||
|
||||
switch r.which {
|
||||
switch res.which {
|
||||
case ResponseHealth:
|
||||
all.health = r.health
|
||||
all.health = res.health
|
||||
case ResponseCcr:
|
||||
all.ccr = r.ccr
|
||||
all.ccr = res.ccr
|
||||
case ResponseInfo:
|
||||
all.info = r.info
|
||||
all.info = res.info
|
||||
case ResponseStats:
|
||||
all.stats = r.stats
|
||||
all.stats = res.stats
|
||||
case ResponseIndices:
|
||||
all.indices = r.indices
|
||||
all.indices = res.indices
|
||||
case ResponseTasks:
|
||||
all.tasks = r.tasks
|
||||
all.tasks = res.tasks
|
||||
case ResponseHealthReport:
|
||||
all.healthreport = r.healthreport
|
||||
all.healthreport = res.healthreport
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,8 +155,10 @@ func ClusterStatus(conf *cfg.Config) error {
|
||||
|
||||
slog.Debug("ES result", "cluster health", res.health)
|
||||
|
||||
var isleader bool
|
||||
var ccrfollowing string
|
||||
var (
|
||||
isleader bool
|
||||
ccrfollowing string
|
||||
)
|
||||
|
||||
if res.ccr != nil {
|
||||
isleader = len(res.ccr.AutoFollowStats.AutoFollowedClusters) == 0
|
||||
@@ -171,6 +175,7 @@ func ClusterStatus(conf *cfg.Config) error {
|
||||
|
||||
// look for red indices, if any
|
||||
redindices := 0
|
||||
|
||||
for _, index := range *res.indices {
|
||||
if *index.Health == "red" {
|
||||
redindices++
|
||||
@@ -179,6 +184,7 @@ func ClusterStatus(conf *cfg.Config) error {
|
||||
|
||||
// look for long running tasks
|
||||
longtasks := 0
|
||||
|
||||
for _, task := range *res.tasks {
|
||||
if strings.Contains(*task.RunningTime, "d") {
|
||||
longtasks++
|
||||
@@ -211,7 +217,7 @@ func ClusterStatus(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
if conf.Verbose {
|
||||
table = gatherClusterStats(conf, res.stats, table)
|
||||
table = gatherClusterStats(res.stats, table)
|
||||
}
|
||||
|
||||
if res.health.Status.Name != "green" {
|
||||
@@ -239,9 +245,11 @@ func ClusterStatus(conf *cfg.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func gatherClusterStats(conf *cfg.Config, clusterstats *clusterstats.Response, table *printer.Table) *printer.Table {
|
||||
var querycount int64
|
||||
var vmversion string
|
||||
func gatherClusterStats(clusterstats *clusterstats.Response, table *printer.Table) *printer.Table {
|
||||
var (
|
||||
querycount int64
|
||||
vmversion string
|
||||
)
|
||||
|
||||
for _, count := range clusterstats.Indices.Search.Queries {
|
||||
querycount += count
|
||||
|
||||
Reference in New Issue
Block a user