es

package
v0.1.140 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config map[string]interface{}) (interface{}, error)

Elasticsearch client component,Support for batch and asynchronous writes. support read-write splitting, configuration: components:

es:
    esHost: "http://127.0.0.1:9200/"
    httpId:    "http" // 默认http
    retryNum: 0 // 默认0重试1次
    batchChanLen: 500 // 队列数量 默认500
    batchFlushInterval: "50s" // 批量操作刷新间隔时间 默认50秒
    batchEsTimeout:"30s" // 批量请求es服务器超时时间 默认30秒
    singleEsTimeout: "500ms" // 单个请求es服务器超时时间 默认500毫秒
    maxBufferLine: 600 // 缓冲最条数,默认600
    maxBufferByte: 1048576 // 写缓冲大小 单位bite 默认1M

Types

type Client

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

func (*Client) Batch

func (c *Client) Batch(action, head, body string) error

批量增加命令 异步执行 action : index,create,delete, update head : {“_ index”:“test”,“_ type”:“_ doc”,“_ id”:“1”} body : {"filed1":"value1"}

func (*Client) Close

func (c *Client) Close()

关闭通道,等待处理数据

func (*Client) Flush

func (c *Client) Flush()

刷盘

func (*Client) Init

func (c *Client) Init() error

func (*Client) Process

func (c *Client) Process(item *DataItem)

func (*Client) Request

func (c *Client) Request(method, uri string, body []byte, timeout time.Duration, bulk ...bool) ([]byte, error)

Request 请求es,返回原始结果 method: POST GET PUT .... body: 请求body timeout: 超时设置 bulk: 是否批量操作(默认否)

func (*Client) SetBatchEsTimeout

func (c *Client) SetBatchEsTimeout(v string) error

func (*Client) SetBatchFlushInterval

func (c *Client) SetBatchFlushInterval(v string) error

func (*Client) SetBatchFlushNum

func (c *Client) SetBatchFlushNum(v int)

func (*Client) SetEsHost

func (c *Client) SetEsHost(v string)

func (*Client) SetMaxBufferByte

func (c *Client) SetMaxBufferByte(v int)

func (*Client) SetMaxBufferLine

func (c *Client) SetMaxBufferLine(v int)

func (*Client) SetRetryNum

func (c *Client) SetRetryNum(v int)

func (*Client) SetSingleEsTimeout

func (c *Client) SetSingleEsTimeout(v string) error

func (*Client) Single

func (c *Client) Single(method, uri string, body []byte, timeout time.Duration) ([]byte, error)

单个提交

type DataItem

type DataItem struct {
	Head string
	Body string
}

数据结构

Jump to

Keyboard shortcuts

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