es

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MulanPSL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNewClient added in v0.1.2

func DefaultNewClient(c *ClientConfig, cc *Config) (es *elasticsearch.Client, err error)

func OperationApiLog added in v0.1.3

func OperationApiLog(c *Client, op, idx, body string) func()

Types

type Client

type Client struct {
	Client *elasticsearch.Client
	Cfg    ClientConfig

	Log          logger.Interface
	CreateClient func(c *ClientConfig, cc *Config) (es *elasticsearch.Client, err error)
	// contains filtered or unexported fields
}

func (*Client) CliFlags

func (c *Client) CliFlags(name string) []cli.Flag

func (*Client) Load

func (c *Client) Load(name string, cfg *Config) (err error)

func (*Client) Ref

func (c *Client) Ref() *Component

type ClientConfig

type ClientConfig struct {
	Host        []string `json:"host"       yaml:"host"`
	Pwd         string   `json:"password"   yaml:"password"`
	User        string   `json:"user"       yaml:"user"`
	MaxIdleConn int      `json:"idle_limit" yaml:"idle_limit"`
}

type Component

type Component struct {
	DSNPrint bool
	Cfg      Config
	Clts     map[string]*Client
}

func (*Component) CliFlags

func (c *Component) CliFlags() []cli.Flag

func (*Component) Close

func (c *Component) Close(_ logger.Interface, _ gsf.Config) (err error)

func (*Component) Init

func (c *Component) Init(log logger.Interface, cfg gsf.Config) error

func (*Component) Run

func (c *Component) Run(_ logger.Interface, _ gsf.Config) error

type Config

type Config struct {
	MaxConnTime   int `json:"max_con_time"    yaml:"max_con_time"`
	MaxIdleTime   int `json:"max_idle_time"   yaml:"max_idle_time"`
	KeepAliveTime int `json:"keep_alive_time" yaml:"keep_alive_time"`
	SlowThreshold int `json:"slow_threshold"  yaml:"slow_threshold"`
}

type Operation

type Operation struct {
	ApiLog func(c *Client, op, idx, body string) func()
	// contains filtered or unexported fields
}

func NewOperation

func NewOperation(c *Client) *Operation

func (*Operation) Search

func (c *Operation) Search(idx string, body string, receive interface{}, ctx context.Context) (cnt uint64, err error)

type RespBasic

type RespBasic struct {
	Took     uint64 `json:"took"`
	TimedOut bool   `json:"timed_out"`
}

type RespError

type RespError struct {
	Status uint64 `json:"status"`
	Error  struct {
		Type   string `json:"type"`
		Reason string `json:"reason"`
	} `json:"error"`
}

type RespSearch

type RespSearch struct {
	RespBasic
	Hits struct {
		Total struct {
			Value    uint64 `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		Hits interface{} `json:"hits"`
	} `json:"hits"`
}

type RespSearchItem

type RespSearchItem[T any] struct {
	Id     string `json:"_id"`
	Source T      `json:"_source"`
}

Jump to

Keyboard shortcuts

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