basetool

package
v0.0.0-...-6d2deb8 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool is a generated GoMock package.

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool implements a tool of es

Package basetool implements a tool of es

Index

Constants

View Source
const (
	Green  = "green"
	Yellow = "yellow"
	Red    = "red"

	GET    = "GET"
	PUT    = "PUT"
	POST   = "POST"
	DELETE = "DELETE"
	HEAD   = "HEAD"
	PATCH  = "PATCH"
	TRACE  = "TRACE"

	Open  = "open"
	Close = "close"

	Cmd            = "Cmd"
	CommonFile     = "CommonFile"
	RequestProto   = "RequestProto"
	ClientCertFile = "ClientCertFile"
	ClientKeyFile  = "ClientKeyFile"
	CaCertFile     = "CaCertFile"
	IPPort         = "IPPort"
	Http           = "http"
	Https          = "https"
	ClusterName    = "ClusterName"
	IndexName      = "IndexName"
	IndicesPath    = "IndicesPath"
	SettingsPath   = "SettingsPath"
	WaitSeconds    = "WaitSeconds" // 等待时间,默认为10s
	MappingPath    = "MappingPath"
	OpDirection    = "OpDirection"
	OpIndexNum     = "OpIndexNum"

	GetClusterHealth              = "GetClusterHealth"
	GetClusterSettings            = "GetClusterSettings"
	CheckClusterName              = "CheckClusterName"
	GetIndiceStatus               = "GetIndiceStatus"
	SetIndiceAllocationOnAndOff   = "SetIndiceAllocationOnAndOff"
	CreateIndices                 = "CreateIndices"
	GetUnhealthIndicesWithNoClose = "GetUnhealthIndicesWithNoClose"
	GetCloseIndices               = "GetCloseIndices"
	GetWholeIndices               = "GetWholeIndices"
	RecoveryUnhealthIndices       = "RecoveryUnhealthIndices"
	SetIndiceSettings             = "SetIndiceSettings"
	GetIndiceSettings             = "GetIndiceSettings"
	GetIndiceMapping              = "GetIndiceMapping"
	SetIndiceMapping              = "SetIndiceMapping"
	DataSink                      = "DataSink"
	GetCurrentRecovery            = "GetCurrentRecovery"
	CloseIndices                  = "CloseIndices"
	OpenIndices                   = "OpenIndices"
	DeleteClosedIndices           = "DeleteClosedIndices"

	// 并行恢复index时选择的方向
	Positive      = 0
	Reverse       = 1
	BiDirectional = 2

	MaxConcurrentIndexNum = 4 // 同一时刻最多并行4个index恢复
)
View Source
const (
	Ok = 0

	ErrInvalidParam         = -10000
	ErrInternalServerFailed = -10001
	ErrInvalidIndex         = -10002
	ErrInvalidNumber        = -10003
	ErrInvalidContent       = -10004

	ErrNotFound        = -10100
	ErrNotEqual        = -10101
	ErrMakeDirFailed   = -10102
	ErrOpenFileFailed  = -10103
	ErrWriteFileFailed = -10104
	ErrReadLineFailed  = -10105
	ErrStatFileFailed  = -10106

	ErrHttpDoFailed         = -10200
	ErrNewRequestFailed     = -10201
	ErrIoUtilReadAllFailed  = -10202
	ErrIoUtilReadFileFailed = -10203

	ErrTlsLoadX509Failed = -10300

	ErrJsonUnmarshalFailed = -10400
	ErrJsonMarshalFailed   = -10401

	ErrAtoiFailed = -10500

	ErrRespErr = -10600

	ErrNotClosed = -10700
)
View Source
const (
	ESToolVersion = "0.0.3"
)

Variables

This section is empty.

Functions

func Assert

func Assert(flag bool, info interface{})

Assert Implemation of Assert function

func CheckExist

func CheckExist(key string, arr []string) bool

CheckExist Check whether key exist in arr

func DecodeErr

func DecodeErr(err error) (int, string)

DecodeErr Decode internal Error

func Diff

func Diff(prefixName string, before, after string) error

Diff Get the difference of two string

func GetLines

func GetLines(content []byte) ([]string, error)

GetLines Get lines of content

func IsDir

func IsDir(path string) (bool, error)

IsDir 判断所给路径是否为文件夹

func ReadAllLinesInFile

func ReadAllLinesInFile(filePath string) ([]string, error)

ReadAllLinesInFile Read all lines in a file and return them in a string array.

func ReadCfgFile

func ReadCfgFile(filePath string) (map[string]string, error)

ReadCfgFile Read config file and return configs as map. Each line in config file should be like "key value", such as "username Tom".

func ReadWholeFile

func ReadWholeFile(path string) ([]byte, error)

ReadWholeFile Get content of whole file

func SortStringArr

func SortStringArr(arr []string, direction int) error

SortStringArr sort array according direction

Types

type BaseEsOp

type BaseEsOp interface {
	Get(uri string) ([]byte, error)
	Put(uri string, params string) ([]byte, error)
	Post(uri string, params string) ([]byte, error)
	Delete(uri string) ([]byte, error)
}

BaseEsOp interface for operating es

type CompositeOp

type CompositeOp struct {
	EsOp BaseEsOp
}

CompositeOp operation using http or https

func Create

func Create(esOp BaseEsOp) *CompositeOp

Create Get real operation of es

func (*CompositeOp) CheckClusterName

func (compositeOp *CompositeOp) CheckClusterName(expectClusterName string) (bool, error)

CheckClusterName Check cluster name

func (*CompositeOp) CloseIndice

func (compositeOp *CompositeOp) CloseIndice(clusterName, indexName string) error

CloseIndice Close indice

func (*CompositeOp) CreateIndice

func (compositeOp *CompositeOp) CreateIndice(clusterName, indexName string, waitSeconds int) error

CreateIndice Create indice and set allcation off

func (*CompositeOp) DeleteClosedIndice

func (compositeOp *CompositeOp) DeleteClosedIndice(clusterName, indexName string) error

DeleteClosedIndice Delete close indice

func (*CompositeOp) GetClusterHealth

func (compositeOp *CompositeOp) GetClusterHealth() (map[string]interface{}, string, error)

GetClusterHealth Get health information of cluster

func (*CompositeOp) GetClusterSettings

func (compositeOp *CompositeOp) GetClusterSettings() (map[string]interface{}, string, error)

GetClusterSettings Get cluster settings

func (*CompositeOp) GetClusterSettingsOfKey

func (compositeOp *CompositeOp) GetClusterSettingsOfKey(key string) (interface{}, error)

GetClusterSettingsOfKey Get special setting of cluster example: persistent.cluster.routing.allocation.enable

func (*CompositeOp) GetIndexMapping

func (compositeOp *CompositeOp) GetIndexMapping(indexName string) (map[string]interface{}, string, error)

GetIndexMapping Get indice mapping

func (*CompositeOp) GetIndexSettings

func (compositeOp *CompositeOp) GetIndexSettings(indexName string) (map[string]interface{}, string, error)

GetIndexSettings Get indice settings

func (*CompositeOp) GetIndexSettingsOfKey

func (compositeOp *CompositeOp) GetIndexSettingsOfKey(indexName string, key string) (interface{}, error)

GetIndexSettingsOfKey Get specail setting of indice

func (*CompositeOp) GetIndice

func (compositeOp *CompositeOp) GetIndice(indexName string) ([]IndiceInfo, error)

GetIndice Get special indice

func (*CompositeOp) GetIndices

func (compositeOp *CompositeOp) GetIndices() ([]IndiceInfo, error)

GetIndices Get all indices information

func (*CompositeOp) GetIndicesStartWith

func (compositeOp *CompositeOp) GetIndicesStartWith(prefix string) ([]IndiceInfo, error)

GetIndicesStartWith Get information of indices with prefix

func (*CompositeOp) GetRecoveryInfo

func (compositeOp *CompositeOp) GetRecoveryInfo() (map[string]interface{}, string, error)

GetRecoveryInfo Get recovery infomation of cluster

func (*CompositeOp) GetSpecialHealthIndices

func (compositeOp *CompositeOp) GetSpecialHealthIndices(health string) ([]IndiceInfo, error)

GetSpecialHealthIndices Get indiecs of special health

func (*CompositeOp) GetSpecialStatusIndices

func (compositeOp *CompositeOp) GetSpecialStatusIndices(status string) ([]IndiceInfo, error)

GetSpecialStatusIndices Get indices of special status

func (*CompositeOp) OpenIndice

func (compositeOp *CompositeOp) OpenIndice(clusterName, indexName string) error

OpenIndice Open indice

func (*CompositeOp) SetBatchIndiceAllocationOnAndOff

func (compositeOp *CompositeOp) SetBatchIndiceAllocationOnAndOff(clusterName string, indicesName []string,
	waitSeconds int) error

SetBatchIndiceAllocationOnAndOff FirstsSet allocation on batch indices which will be recovered Second set allocation off

func (*CompositeOp) SetIndiceAllocationOnAndOff

func (compositeOp *CompositeOp) SetIndiceAllocationOnAndOff(clusterName, indexName string,
	waitSeconds int) error

SetIndiceAllocationOnAndOff First set allocation on so indice could be recovered Second set allocation off

func (*CompositeOp) SetIndiceMapping

func (compositeOp *CompositeOp) SetIndiceMapping(clusterName, indexName, mappings string) error

SetIndiceMapping Set indice mapping

func (*CompositeOp) SetIndiceSettings

func (compositeOp *CompositeOp) SetIndiceSettings(clusterName, indexName, settings string) error

SetIndiceSettings Set indice setttings

type Error

type Error struct {
	Code    int
	Message string
}

Error error including code and message

func (Error) Error

func (e Error) Error() string

Error implemation Error interface

type EsOpNoTls

type EsOpNoTls struct {
	IpPort string
}

EsOpNoTls operation using http

func (*EsOpNoTls) Delete

func (esOpNoTls *EsOpNoTls) Delete(uri string) ([]byte, error)

Delete interface of http

func (*EsOpNoTls) Get

func (esOpNoTls *EsOpNoTls) Get(uri string) ([]byte, error)

Get interface of http

func (*EsOpNoTls) Post

func (esOpNoTls *EsOpNoTls) Post(uri string, params string) ([]byte, error)

Post interface of http

func (*EsOpNoTls) Put

func (esOpNoTls *EsOpNoTls) Put(uri string, params string) ([]byte, error)

Put interface of http

type EsOpWithTls

type EsOpWithTls struct {
	IpPort         string
	ClientCertFile string
	ClientKeyFile  string
	CaCertFile     string
}

EsOpWithTls operation using https

func (*EsOpWithTls) Delete

func (esOpWithTls *EsOpWithTls) Delete(uri string) ([]byte, error)

Delete interface of https

func (*EsOpWithTls) Get

func (esOpWithTls *EsOpWithTls) Get(uri string) ([]byte, error)

Get interface of https

func (*EsOpWithTls) Post

func (esOpWithTls *EsOpWithTls) Post(uri string, params string) ([]byte, error)

Post interface of https

func (*EsOpWithTls) Put

func (esOpWithTls *EsOpWithTls) Put(uri string, params string) ([]byte, error)

Put interface of https

type IndiceInfo

type IndiceInfo struct {
	Health string // green, yellow, red
	Status string // open, close
	Name   string
	Uuid   string
}

IndiceInfo indice information including health status

type MockBaseEsOp

type MockBaseEsOp struct {
	// contains filtered or unexported fields
}

MockBaseEsOp is a mock of BaseEsOp interface.

func NewMockBaseEsOp

func NewMockBaseEsOp(ctrl *gomock.Controller) *MockBaseEsOp

NewMockBaseEsOp creates a new mock instance.

func (*MockBaseEsOp) Delete

func (m *MockBaseEsOp) Delete(uri string) ([]byte, error)

Delete mocks base method.

func (*MockBaseEsOp) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBaseEsOp) Get

func (m *MockBaseEsOp) Get(uri string) ([]byte, error)

Get mocks base method.

func (*MockBaseEsOp) Post

func (m *MockBaseEsOp) Post(uri, params string) ([]byte, error)

Post mocks base method.

func (*MockBaseEsOp) Put

func (m *MockBaseEsOp) Put(uri, params string) ([]byte, error)

Put mocks base method.

type MockBaseEsOpMockRecorder

type MockBaseEsOpMockRecorder struct {
	// contains filtered or unexported fields
}

MockBaseEsOpMockRecorder is the mock recorder for MockBaseEsOp.

func (*MockBaseEsOpMockRecorder) Delete

func (mr *MockBaseEsOpMockRecorder) Delete(uri interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockBaseEsOpMockRecorder) Get

func (mr *MockBaseEsOpMockRecorder) Get(uri interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockBaseEsOpMockRecorder) Post

func (mr *MockBaseEsOpMockRecorder) Post(uri, params interface{}) *gomock.Call

Post indicates an expected call of Post.

func (*MockBaseEsOpMockRecorder) Put

func (mr *MockBaseEsOpMockRecorder) Put(uri, params interface{}) *gomock.Call

Put indicates an expected call of Put.

Jump to

Keyboard shortcuts

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