eslite

package module
v0.0.0-...-6f27c9e Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 15 Imported by: 0

README

#eslite

es write wrapper

##interface

type ESLite interface {
	Open(host string, port int) error
	Close()
	Begin() error
	Write(index string, id string,
		typ string, v interface{}) error

	WriteDirect(index string, id string,
		typ string, v interface{}) error

	Commit() error
}

##demo

var es eslite.ESLite
var ESPort int
var ESEngine,EsHost string
//...
//configure ...
//...
switch ESEngine {
case "ElasticClientV":
	es = &eslite.ElasticClientV1{}
case "ElasticClientV2":
	es = &eslite.ElasticClientV2{}
case "ElasticClientV3":
	es = &eslite.ElasticClientV3{}
case "ElasticClientV5":
	es = &eslite.ElasticClientV5{}
case "ElasticGoClient":
	es = &eslite.ElasticGoClient{}
default:
	es = &eslite.ElasticGoClient{}
}
if err := es.Open(cfg.EsHost, cfg.ESPort, "", ""); err != nil {
	logrus.Error("Open es error ", err)
	return
}
//bacth write
es.Begin()

var idx int
for {
	es.Write(xxxxxxxx)
	idx++
	if idx%512==0{
		es.Commit()
		es.Begin()
	}
}

note

disable sniffing ElasticClientV2 ElasticClientV3 ElasticClientV5

history

2018/08/20 add SetPipeline function, only support ElasticClientV5, ElasticClientV6

Documentation

Overview

eslite: Package for a simple elasticsearch writer, support es1~es6

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupportPipeline = errors.New("Only elasticv5,v6 support pipeline")
)

elasticsearch add pipeline feature after version 5.0

Functions

This section is empty.

Types

type ESLite

type ESLite interface {
	Open(host string, port int, userName, pass string) error
	Close()
	Begin() error

	SetPipeline(pipeline string) error

	Write(index string, id string,
		typ string, v interface{}) error

	WriteDirect(index string, id string,
		typ string, v interface{}) error

	Commit() error
}

elasticsearch writer interface

type ElasticClientV1

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

func (*ElasticClientV1) Begin

func (es *ElasticClientV1) Begin() error

begin patch write

func (*ElasticClientV1) Close

func (es *ElasticClientV1) Close()

close elasticsearch connection

func (*ElasticClientV1) Commit

func (es *ElasticClientV1) Commit() error

commit patch write

func (*ElasticClientV1) Open

func (es *ElasticClientV1) Open(host string, port int, userName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV1) SetPipeline

func (es *ElasticClientV1) SetPipeline(pipeline string) error

set elasticsearch pipeline, expect es version>5.0

func (*ElasticClientV1) Write

func (es *ElasticClientV1) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV1) WriteDirect

func (es *ElasticClientV1) WriteDirect(index string, id string,
	typ string, v interface{}) error

write a document directly

type ElasticClientV2

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

func (*ElasticClientV2) Begin

func (es *ElasticClientV2) Begin() error

begin patch write

func (*ElasticClientV2) Close

func (es *ElasticClientV2) Close()

close elasticsearch connection

func (*ElasticClientV2) Commit

func (es *ElasticClientV2) Commit() error

commit patch write

func (*ElasticClientV2) Open

func (es *ElasticClientV2) Open(host string, port int, userName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV2) SetPipeline

func (es *ElasticClientV2) SetPipeline(pipeline string) error

set elasticsearch pipeline

func (*ElasticClientV2) Write

func (es *ElasticClientV2) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV2) WriteDirect

func (es *ElasticClientV2) WriteDirect(index string, id string,
	typ string, v interface{}) error

write a document directly

type ElasticClientV3

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

ElasticClientV3 object

func (*ElasticClientV3) Begin

func (es *ElasticClientV3) Begin() error

begin patch write

func (*ElasticClientV3) Close

func (es *ElasticClientV3) Close()

close elasticsearch connection

func (*ElasticClientV3) Commit

func (es *ElasticClientV3) Commit(pipeline string) error

commit patch write

func (*ElasticClientV3) Open

func (es *ElasticClientV3) Open(host string, port int, userName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV3) SetPipeline

func (es *ElasticClientV3) SetPipeline(pipeline string) error

set elasticsearch pipeline, expect es version>5.0

func (*ElasticClientV3) Write

func (es *ElasticClientV3) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV3) WriteDirect

func (es *ElasticClientV3) WriteDirect(index string, id string,
	typ string, v interface{}) error

write a document directly

type ElasticClientV5

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

func (*ElasticClientV5) Begin

func (es *ElasticClientV5) Begin() error

begin patch write

func (*ElasticClientV5) Close

func (es *ElasticClientV5) Close()

close elasticsearch connection

func (*ElasticClientV5) Commit

func (es *ElasticClientV5) Commit() error

commit patch write

func (*ElasticClientV5) Open

func (es *ElasticClientV5) Open(host string, port int, usrName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV5) SetPipeline

func (es *ElasticClientV5) SetPipeline(pipeline string) error

set elasticsearch pipeline

func (*ElasticClientV5) Write

func (es *ElasticClientV5) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV5) WriteDirect

func (es *ElasticClientV5) WriteDirect(index string, id string,
	typ string, v interface{}) error

write a document directly

type ElasticClientV6

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

ElasticClientV6 object

func (*ElasticClientV6) Begin

func (es *ElasticClientV6) Begin() error

begin patch write

func (*ElasticClientV6) Close

func (es *ElasticClientV6) Close()

close elasticsearch connection

func (*ElasticClientV6) Commit

func (es *ElasticClientV6) Commit() error

commit patch write

func (*ElasticClientV6) Open

func (es *ElasticClientV6) Open(host string, port int, usrName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV6) SetPipeline

func (es *ElasticClientV6) SetPipeline(pipeline string) error

set elasticsearch pipeline

func (*ElasticClientV6) Write

func (es *ElasticClientV6) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV6) WriteDirect

func (es *ElasticClientV6) WriteDirect(index, id, typ string,
	v interface{}) error

write a document directly

type ElasticClientV7

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

ElasticClientV7 object

func (*ElasticClientV7) Begin

func (es *ElasticClientV7) Begin() error

begin patch write

func (*ElasticClientV7) Close

func (es *ElasticClientV7) Close()

close elasticsearch connection

func (*ElasticClientV7) Commit

func (es *ElasticClientV7) Commit() error

commit patch write

func (*ElasticClientV7) Open

func (es *ElasticClientV7) Open(host string, port int, usrName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticClientV7) SetPipeline

func (es *ElasticClientV7) SetPipeline(pipeline string) error

set elasticsearch pipeline

func (*ElasticClientV7) Write

func (es *ElasticClientV7) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticClientV7) WriteDirect

func (es *ElasticClientV7) WriteDirect(index, id, typ string,
	v interface{}) error

write a document directly

type ElasticGoClient

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

func (*ElasticGoClient) Begin

func (es *ElasticGoClient) Begin() error

begin patch write

func (*ElasticGoClient) Close

func (es *ElasticGoClient) Close()

close elasticsearch connection

func (*ElasticGoClient) Commit

func (es *ElasticGoClient) Commit() error

commit patch write

func (*ElasticGoClient) Open

func (es *ElasticGoClient) Open(host string, port int, userName, pass string) error

open: connect with elasticsearch by user:pass@host:port

func (*ElasticGoClient) SetPipeline

func (es *ElasticGoClient) SetPipeline(pipeline string) error

set elasticsearch pipeline, expect elasticsearch version>=5.0

func (*ElasticGoClient) Write

func (es *ElasticGoClient) Write(index string, id string,
	typ string, v interface{}) error

patch write elastic document

func (*ElasticGoClient) WriteDirect

func (es *ElasticGoClient) WriteDirect(index string, id string,
	typ string, v interface{}) error

write a document directly

Jump to

Keyboard shortcuts

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