elasticsearch

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcTotalShardNum

func CalcTotalShardNum(shardNum int, replicaNum int) int

func ExtractError

func ExtractError(resp *http.Response) error

Types

type Client

type Client interface {
	GetNodeStats(ctx context.Context) (*NodeStats, error)
	GetIndexSettings(ctx context.Context, indexName string) (*IndexSettings, error)
	GetIndexHealth(ctx context.Context, indexName string) (*IndexHealth, error)
	UpdateIndexReplicaNum(ctx context.Context, indexName string, replicaNum int) error
}

func NewClient

func NewClient(esClient *esv8.TypedClient) Client

type IndexHealth

type IndexHealth struct {
	ClusterName                 string  `json:"cluster_name"`
	Status                      string  `json:"status"`
	NumberOfNodes               int     `json:"number_of_nodes"`
	NumberOfDataNodes           int     `json:"number_of_data_nodes"`
	ActivePrimaryShards         int     `json:"active_primary_shards"`
	ActiveShards                int     `json:"active_shards"`
	RelocatingShards            int     `json:"relocating_shards"`
	InitializingShards          int     `json:"initializing_shards"`
	UnassignedShards            int     `json:"unassigned_shards"`
	DelayedUnassignedShards     int     `json:"delayed_unassigned_shards"`
	NumberOfPendingTasks        int     `json:"number_of_pending_tasks"`
	NumberOfInFlightFetch       int     `json:"number_of_in_flight_fetch"`
	TaskMaxWaitingInQueueMillis int     `json:"task_max_waiting_in_queue_millis"`
	ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"`
}

func (*IndexHealth) IsHealthy

func (i *IndexHealth) IsHealthy() bool

type IndexSettings

type IndexSettings struct {
	ShardNum   int `json:"number_of_shards,string"`
	ReplicaNum int `json:"number_of_replicas,string"`
}

func (*IndexSettings) TotalShardNum

func (i *IndexSettings) TotalShardNum() int

TotalShardNum returns total shard count of primary + replica shards

type NodeStats

type NodeStats struct {
	Nodes map[string]*NodeStatsNode `json:"nodes"`
}

func (*NodeStats) DataContentNodes

func (n *NodeStats) DataContentNodes() NodeStatsNodes

type NodeStatsNode

type NodeStatsNode struct {
	ID    string           `json:"-"`
	Roles []string         `json:"roles"`
	OS    *NodeStatsNodeOS `json:"os"`
}

type NodeStatsNodeOS

type NodeStatsNodeOS struct {
	CPU *NodeStatsNodeOSCPU `json:"cpu"`
}

type NodeStatsNodeOSCPU

type NodeStatsNodeOSCPU struct {
	Percent float64 `json:"percent"`
}

type NodeStatsNodes

type NodeStatsNodes []*NodeStatsNode

func (NodeStatsNodes) AvgCPUUtil

func (n NodeStatsNodes) AvgCPUUtil() float64

func (NodeStatsNodes) IDs

func (n NodeStatsNodes) IDs() []string

func (NodeStatsNodes) TotalCPUUtil

func (n NodeStatsNodes) TotalCPUUtil() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL