rollover

package
v0.0.0-...-33be62f Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package rollover implements elasticsearch rollover tasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindRolloverIndices

func BindRolloverIndices()

BindRolloverIndices bind the task to rollover indices

func FilterReadyToBeDeleteIndices

func FilterReadyToBeDeleteIndices(aliasURL string, allIdx []string) (indices []string, err error)

FilterReadyToBeDeleteIndices filter indices that is ready to be deleted

func FilterToBeDeleteIndicies

func FilterToBeDeleteIndicies(allInd []string,
	idxSt *IdxSetting) (indices []string, err error)

FilterToBeDeleteIndicies return the indices that need be delete

func GetAliasURL

func GetAliasURL(st *IdxSetting) string

GetAliasURL return the ES alisese endpoint

func GetIdxRolloverReqBodyByIdxAlias

func GetIdxRolloverReqBodyByIdxAlias(idxSt *IdxSetting) (jb *bytes.Buffer, err error)

func IsIdxIsWriteAlias

func IsIdxIsWriteAlias(idx string, aliases []*AliasesResp) (ret bool)

IsIdxIsWriteAlias check is indices' alias is write-alias

func IsIdxShouldDelete

func IsIdxShouldDelete(now time.Time,
	dateStr string,
	expires time.Duration) (bool, error)

IsIdxShouldDelete check whether a index is should tobe deleted dateStr like `2016.10.31`, treated as +0800

func LoadAllIndicesNames

func LoadAllIndicesNames(api string) (indices []string, err error)

LoadAllIndicesNames load all indices name by ES API

func NewIndex

func NewIndex(ctx context.Context, api string, st *IdxSetting) (err error)

func RemoveIndexByName

func RemoveIndexByName(ctx context.Context, api, index string) (err error)

RemoveIndexByName delete index by elasticsearch RESTful API

func RunDeleteTask

func RunDeleteTask(ctx context.Context, sem *semaphore.Weighted, st *IdxSetting)

RunDeleteTask start to delete indices

func RunRolloverTask

func RunRolloverTask(ctx context.Context, sem *semaphore.Weighted, st *IdxSetting)

Types

type AliasesResp

type AliasesResp struct {
	Index string `json:"index"`
}

AliasesResp is the response of es aliases API

func LoadAliases

func LoadAliases(url string) (aliases []*AliasesResp, err error)

LoadAliases load all indices aliases from ES

type IdxSetting

type IdxSetting struct {
	Regexp        *regexp.Regexp
	Rollover      string
	Expires       time.Duration
	IdxAlias      string
	NRepls        int
	NShards       int
	IdxWriteAlias string
	Mapping       template.HTML
	API           string
	IsSkipCreate  bool
}

IdxSetting is the task settings

func LoadSettings

func LoadSettings() (idxSettings []*IdxSetting, err error)

LoadSettings load task settings

Jump to

Keyboard shortcuts

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