elasticsearch

package
v0.5.7-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResourceGroupRuleNotFound = fmt.Errorf("resource group rule not found")
	ErrResourceGroupNotFound     = fmt.Errorf("resource group not found")
)
View Source
var ErrNotFound = fmt.Errorf("object not found")

Functions

func ConvertResourceGroup2Map

func ConvertResourceGroup2Map(rg *entity.ResourceGroup) (map[string]any, error)

ConvertResourceGroup2Map converts a ResourceGroup to a map[string]any.

func Parse

func Parse(queryString string) ([]storage.Query, error)

Parse takes a query string and returns a slice of storage.Query and an error if any.

func ParseQueries

func ParseQueries(queries []storage.Query) (map[string]interface{}, error)

ParseQueries takes a slice of storage.Query and returns a map of interface{} representing the parsed queries and an error if any.

Types

type Config

type Config struct {
	Addresses []string `env:"ES_ADDRESSES"`
	UserName  string   `env:"ES_USER"`
	Password  string   `env:"ES_PASSWORD"`
}

Config defines the configuration structure for Elasticsearch storage.

type GeneralStorageGetter added in v0.4.8

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

GeneralStorageGetter retrieves and returns a general storage instance based on the provided configuration.

func NewGeneralStorageGetter added in v0.4.8

func NewGeneralStorageGetter(addresses []string, userName, password string) *GeneralStorageGetter

NewGeneralStorageGetter creates a new instance of the GeneralStorageGetter with the given Elasticsearch addresses, user name, and password.

func (*GeneralStorageGetter) GetGeneralStorage added in v0.4.8

func (s *GeneralStorageGetter) GetGeneralStorage() (storage.Storage, error)

GetGeneralStorage retrieves and returns a storage instance based on the provided configuration.

type Pagination

type Pagination struct {
	Page     int
	PageSize int
}

Pagination defines the struct for pagination which contains page number and page size.

type ResourceGroupRuleStorageGetter

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

ResourceGroupRuleStorageGetter represents a structure for getting resource group rule storage instances.

func NewResourceGroupRuleStorageGetter

func NewResourceGroupRuleStorageGetter(addresses []string, userName, password string) *ResourceGroupRuleStorageGetter

NewResourceGroupRuleStorageGetter creates a new instance of the ResourceGroupRuleStorageGetter with the given Elasticsearch addresses, user name, and password.

func (*ResourceGroupRuleStorageGetter) GetResourceGroupRuleStorage

func (s *ResourceGroupRuleStorageGetter) GetResourceGroupRuleStorage() (storage.ResourceGroupRuleStorage, error)

GetResourceGroupRuleStorage retrieves and returns a resource group rule storage instance based on the provided configuration.

type ResourceStorageGetter

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

ResourceStorageGetter represents a structure for getting resource storage instances.

func NewResourceStorageGetter

func NewResourceStorageGetter(addresses []string, userName, password string) *ResourceStorageGetter

NewResourceStorageGetter creates a new instance of the ResourceStorageGetter with the given Elasticsearch addresses, user name, and password.

func (*ResourceStorageGetter) GetResourceStorage

func (s *ResourceStorageGetter) GetResourceStorage() (storage.ResourceStorage, error)

GetResourceStorage retrieves and returns a resource storage instance based on the provided configuration.

type SearchStorageGetter

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

SearchStorageGetter represents a structure for getting search storage instances.

func NewSearchStorageGetter

func NewSearchStorageGetter(addresses []string, userName, password string) *SearchStorageGetter

NewSearchStorageGetter creates a new instance of the SearchStorageGetter with the given Elasticsearch addresses, user name, and password.

func (*SearchStorageGetter) GetSearchStorage

func (s *SearchStorageGetter) GetSearchStorage() (storage.SearchStorage, error)

GetSearchStorage retrieves and returns a search storage instance based on the provided configuration.

type Storage

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

Storage is the struct that holds the necessary fields for interacting with the Elasticsearch cluster.

func NewStorage

func NewStorage(cfg esv8.Config) (*Storage, error)

NewStorage creates and returns a new instance of the Storage struct with the provided Elasticsearch configuration.

func (*Storage) AggregateByTerms

func (s *Storage) AggregateByTerms(ctx context.Context, keys []string) (*storage.AggregateResults, error)

AggregateByTerms performs an aggregation operation using the provided list of keys and returns the results.

func (*Storage) CheckStorageHealth added in v0.4.8

func (s *Storage) CheckStorageHealth(ctx context.Context) error

CheckStorageHealth checks the health of the Elasticsearch storage by pinging the client.

func (*Storage) CountResourceGroupRules

func (s *Storage) CountResourceGroupRules(ctx context.Context) (int, error)

CountResourceGroupRules return a count of resource group rules in the Elasticsearch storage.

func (*Storage) CountResources

func (s *Storage) CountResources(ctx context.Context) (int, error)

CountResources return a count of resources in the Elasticsearch storage.

func (*Storage) DeleteAllResources

func (s *Storage) DeleteAllResources(ctx context.Context, cluster string) error

DeleteAllResources removes all resources from the Elasticsearch storage for the specified cluster.

func (*Storage) DeleteResource

func (s *Storage) DeleteResource(ctx context.Context, cluster string, obj runtime.Object) error

DeleteResource removes an object from the Elasticsearch storage for the specified cluster.

func (*Storage) DeleteResourceGroupRule

func (s *Storage) DeleteResourceGroupRule(ctx context.Context, name string) error

DeleteResourceGroupRule deletes a resource group rule based on the given name.

func (*Storage) GetResource

func (s *Storage) GetResource(ctx context.Context, cluster string, obj runtime.Object) error

GetResource retrieves an object from the Elasticsearch storage for the specified cluster.

func (*Storage) GetResourceGroupRule

func (s *Storage) GetResourceGroupRule(ctx context.Context, name string) (*entity.ResourceGroupRule, error)

GetResourceGroupRule retrieves a resource group rule based on the given name.

func (*Storage) ListResourceGroupRules

func (s *Storage) ListResourceGroupRules(ctx context.Context) ([]*entity.ResourceGroupRule, error)

ListResourceGroupRules lists all resource group rules by searching the entire index.

func (*Storage) ListResourceGroupsBy

func (s *Storage) ListResourceGroupsBy(ctx context.Context, ruleName string) (*storage.ResourceGroupResult, error)

ListResourceGroupsBy lists all resource groups by specified resource group rule name.

func (*Storage) Refresh added in v0.5.5

func (s *Storage) Refresh(ctx context.Context) error

Refresh will update ES index. If you want the previous document changes to be searchable immediately, you need to call refresh manually.

Refer to https://www.elastic.co/guide/en/elasticsearch/guide/current/near-real-time.html to see detail.

func (*Storage) SaveResource

func (s *Storage) SaveResource(ctx context.Context, cluster string, obj runtime.Object) error

SaveResource stores an object in the Elasticsearch storage for the specified cluster.

func (*Storage) SaveResourceGroupRule

func (s *Storage) SaveResourceGroupRule(ctx context.Context, data *entity.ResourceGroupRule) error

SaveResourceGroupRule saves a resource group rule to the storage.

func (*Storage) Search

func (s *Storage) Search(ctx context.Context, queryStr, patternType string, pagination *storage.Pagination) (*storage.SearchResult, error)

Search performs a search operation with the given query string, pattern type, and pagination settings.

func (*Storage) SearchByQuery

func (s *Storage) SearchByQuery(ctx context.Context, query map[string]interface{}, pagination *storage.Pagination) (*storage.SearchResult, error)

SearchByQuery performs a search operation using a query map and pagination settings.

func (*Storage) SearchByTerms

func (s *Storage) SearchByTerms(ctx context.Context, keysAndValues map[string]any, pagination *storage.Pagination) (*storage.SearchResult, error)

SearchByTerms performs a search operation with a map of keys and values and pagination information.

func (*Storage) SoftDeleteResource added in v0.5.5

func (s *Storage) SoftDeleteResource(ctx context.Context, cluster string, obj runtime.Object) error

SoftDeleteResource only sets the deleted field to true, not really deletes the data in storage.

Jump to

Keyboard shortcuts

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