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
- func Assert(flag bool, info interface{})
- func CheckExist(key string, arr []string) bool
- func DecodeErr(err error) (int, string)
- func Diff(prefixName string, before, after string) error
- func GetLines(content []byte) ([]string, error)
- func IsDir(path string) (bool, error)
- func ReadAllLinesInFile(filePath string) ([]string, error)
- func ReadCfgFile(filePath string) (map[string]string, error)
- func ReadWholeFile(path string) ([]byte, error)
- func SortStringArr(arr []string, direction int) error
- type BaseEsOp
- type CompositeOp
- func (compositeOp *CompositeOp) CheckClusterName(expectClusterName string) (bool, error)
- func (compositeOp *CompositeOp) CloseIndice(clusterName, indexName string) error
- func (compositeOp *CompositeOp) CreateIndice(clusterName, indexName string, waitSeconds int) error
- func (compositeOp *CompositeOp) DeleteClosedIndice(clusterName, indexName string) error
- func (compositeOp *CompositeOp) GetClusterHealth() (map[string]interface{}, string, error)
- func (compositeOp *CompositeOp) GetClusterSettings() (map[string]interface{}, string, error)
- func (compositeOp *CompositeOp) GetClusterSettingsOfKey(key string) (interface{}, error)
- func (compositeOp *CompositeOp) GetIndexMapping(indexName string) (map[string]interface{}, string, error)
- func (compositeOp *CompositeOp) GetIndexSettings(indexName string) (map[string]interface{}, string, error)
- func (compositeOp *CompositeOp) GetIndexSettingsOfKey(indexName string, key string) (interface{}, error)
- func (compositeOp *CompositeOp) GetIndice(indexName string) ([]IndiceInfo, error)
- func (compositeOp *CompositeOp) GetIndices() ([]IndiceInfo, error)
- func (compositeOp *CompositeOp) GetIndicesStartWith(prefix string) ([]IndiceInfo, error)
- func (compositeOp *CompositeOp) GetRecoveryInfo() (map[string]interface{}, string, error)
- func (compositeOp *CompositeOp) GetSpecialHealthIndices(health string) ([]IndiceInfo, error)
- func (compositeOp *CompositeOp) GetSpecialStatusIndices(status string) ([]IndiceInfo, error)
- func (compositeOp *CompositeOp) OpenIndice(clusterName, indexName string) error
- func (compositeOp *CompositeOp) SetBatchIndiceAllocationOnAndOff(clusterName string, indicesName []string, waitSeconds int) error
- func (compositeOp *CompositeOp) SetIndiceAllocationOnAndOff(clusterName, indexName string, waitSeconds int) error
- func (compositeOp *CompositeOp) SetIndiceMapping(clusterName, indexName, mappings string) error
- func (compositeOp *CompositeOp) SetIndiceSettings(clusterName, indexName, settings string) error
- type Error
- type EsOpNoTls
- type EsOpWithTls
- type IndiceInfo
- type MockBaseEsOp
- type MockBaseEsOpMockRecorder
Constants ¶
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恢复 )
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 )
const (
ESToolVersion = "0.0.3"
)
Variables ¶
This section is empty.
Functions ¶
func CheckExist ¶
CheckExist Check whether key exist in arr
func ReadAllLinesInFile ¶
ReadAllLinesInFile Read all lines in a file and return them in a string array.
func ReadCfgFile ¶
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 ¶
ReadWholeFile Get content of whole file
func SortStringArr ¶
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 (*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 EsOpNoTls ¶
type EsOpNoTls struct {
IpPort string
}
EsOpNoTls operation using 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
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 ¶
func (m *MockBaseEsOp) EXPECT() *MockBaseEsOpMockRecorder
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.
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.