mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 11:04:18 +02:00
enhance cluster status, add word wrap to wide table rows (#62)
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user