enhance cluster status, add word wrap to wide table rows (#62)

This commit is contained in:
T. von Dein
2026-07-02 12:16:59 +02:00
parent e3b96b3e3b
commit b573d63c54
11 changed files with 284 additions and 97 deletions

View File

@@ -18,10 +18,10 @@ package es
import (
"context"
"errors"
"fmt"
"sync"
"codeberg.org/scip/esctl/pkg/cfg"
"github.com/elastic/go-elasticsearch/v9"
"github.com/elastic/go-elasticsearch/v9/typedapi/cat/indices"
"github.com/elastic/go-elasticsearch/v9/typedapi/cat/tasks"
@@ -43,12 +43,14 @@ const (
ResponseTasks
ResponseExplain
ResponseLifecycle
ResponseHealthReport
)
type apiResponse struct {
error error
info *info.Response
health *health.Response
healthreport *HealthReport
ccr *stats.Response
stats *clusterstats.Response
indices *indices.Response
@@ -59,12 +61,16 @@ type apiResponse struct {
which int
}
func getApiData(es *elasticsearch.TypedClient, wg *sync.WaitGroup,
reschan chan apiResponse, which string) {
func getApiData(
conf *cfg.Config,
es *elasticsearch.TypedClient,
wg *sync.WaitGroup,
reschan chan apiResponse,
which string) {
defer wg.Done()
ar := apiResponse{}
arerr := errors.New("")
var arerr error
switch which {
case "health":
@@ -75,6 +81,13 @@ func getApiData(es *elasticsearch.TypedClient, wg *sync.WaitGroup,
ar.which = ResponseHealth
arerr = err
case "healthreport":
report, err := getHealthReport(conf)
ar.healthreport = report
ar.which = ResponseHealthReport
arerr = err
case "info":
res, err := es.Info().
Do(context.Background())
@@ -83,7 +96,7 @@ func getApiData(es *elasticsearch.TypedClient, wg *sync.WaitGroup,
ar.which = ResponseInfo
arerr = err
case "ccrstats":
case "ccr":
res, err := es.Ccr.Stats().
Do(context.Background())