Documentation ¶
Index ¶
- type Action
- type Dispatcher
- type ESOperation
- type ESProxy
- type ESResponseBulk
- type ESResponseCause
- type ESResponseError
- type ESResponseItem
- type ESResponseStatus
- type ESVersion
- type ErrorHandler
- type Logger
- type LoggerType
- type Option
- type OptionFunc
- func WithAddressesOption(addrs []string) OptionFunc
- func WithApiKeyOption(key string) OptionFunc
- func WithCloudIdOption(id string) OptionFunc
- func WithESVersionOption(v ESVersion) OptionFunc
- func WithErrorHandler(h ErrorHandler) OptionFunc
- func WithGlobalQueueSizeOption(size int) OptionFunc
- func WithLoggerOption(logger *Logger) OptionFunc
- func WithPasswordOption(password string) OptionFunc
- func WithTransportOption(tp http.RoundTripper) OptionFunc
- func WithUsernameOption(username string) OptionFunc
- func WithWorkerQueueSizeOption(size int) OptionFunc
- func WithWorkerSizeOption(size int) OptionFunc
- func WithWorkerWaitInterval(d time.Duration) OptionFunc
- type StandardAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { GetOperation() ESOperation GetIndex() string GetDocType() string GetID() string GetDoc() map[string]interface{} }
Action is an operation that could create or update or delete to document.
type Dispatcher ¶
type Dispatcher interface { AddAction(ctx context.Context, action Action) error Start() error Stop() error }
Dispatcher is an interface of workers orchestration that could manage all of Action and control all of the process flows.
func NewDispatcher ¶
func NewDispatcher(opts ...Option) (Dispatcher, error)
NewDispatcher is to make Dispatcher.
type ESOperation ¶
type ESOperation int
ESOperation is a type of elasticsearch.
const ( ES_INDEX ESOperation = iota ES_CREATE ES_UPDATE ES_DELETE )
ESOperation supports to index, create, update, delete.
func (ESOperation) GetString ¶
func (ao ESOperation) GetString() string
GetString converts int to string value.
type ESProxy ¶
type ESProxy interface {
Bulk(ctx context.Context, acts []Action) (bulk *ESResponseBulk, err error)
}
ESProxy is an interface that actually request the elasticserach.
type ESResponseBulk ¶
type ESResponseBulk struct { Errors bool `json:"errors"` Items []ESResponseItem `json:"items"` }
it is response structs of elasticserach.
func (*ESResponseBulk) Count ¶
func (bulk *ESResponseBulk) Count() (success int, fail int)
Count returns a success and fail count.
func (*ESResponseBulk) ResultError ¶ added in v1.0.6
func (bulk *ESResponseBulk) ResultError() error
ResultErrors returns bulk result error.
type ESResponseCause ¶
it is response structs of elasticserach.
type ESResponseError ¶
type ESResponseError struct { Type string `json:"type"` Reason string `json:"reason"` Cause ESResponseCause `json:"caused_by"` }
it is response structs of elasticserach.
type ESResponseItem ¶
type ESResponseItem struct { Index ESResponseStatus `json:"index"` Create ESResponseStatus `json:"create"` Update ESResponseStatus `json:"update"` Delete ESResponseStatus `json:"delete"` }
it is response structs of elasticserach.
type ESResponseStatus ¶
type ESResponseStatus struct { Id string `json:"_id"` Result string `json:"result"` Status int `json:"status"` Error ESResponseError `json:"error"` }
it is response structs of elasticserach.
type Logger ¶
type Logger struct { Type LoggerType Output io.Writer EnableRequestBody bool EnableResponseBody bool }
Logger is an intermediate struct to be changed elastic logger.
func (*Logger) GetESLogger ¶
GetESLogger is to return elastic search logger.
type LoggerType ¶
type LoggerType int
const ( LOGGER_TYPE_TEXT LoggerType = iota LOGGER_TYPE_COLOR LOGGER_TYPE_CURL LOGGER_TYPE_JSON )
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is something for dependency injection.
type OptionFunc ¶
type OptionFunc func(cfg *config)
OptionFunc is a practical struct for Option.
func WithAddressesOption ¶
func WithAddressesOption(addrs []string) OptionFunc
WithAddressesOption has associated a list of elastic search nodes
func WithApiKeyOption ¶
func WithApiKeyOption(key string) OptionFunc
WithApiKeyOption has associated apikey for authorization.
func WithCloudIdOption ¶
func WithCloudIdOption(id string) OptionFunc
WithCloudIdOption has associated cloud-id about endpoint for elastic cloud
func WithESVersionOption ¶
func WithESVersionOption(v ESVersion) OptionFunc
WithESVersionOption has associated version that elastic search nodes are running
func WithErrorHandler ¶
func WithErrorHandler(h ErrorHandler) OptionFunc
WithErrorHandler has associated a handler called when an error is raised.
func WithGlobalQueueSizeOption ¶
func WithGlobalQueueSizeOption(size int) OptionFunc
WithGlobalQueueSizeOption has associated queue size in global.
func WithLoggerOption ¶
func WithLoggerOption(logger *Logger) OptionFunc
WithLoggerOption has associated logger object.
func WithPasswordOption ¶
func WithPasswordOption(password string) OptionFunc
WithPasswordOption has associated password for HTTP basic authentication.
func WithTransportOption ¶
func WithTransportOption(tp http.RoundTripper) OptionFunc
WithTransportOption has associated http transport object.
func WithUsernameOption ¶
func WithUsernameOption(username string) OptionFunc
WithUsernameOption has associated username for HTTP basic authentication.
func WithWorkerQueueSizeOption ¶
func WithWorkerQueueSizeOption(size int) OptionFunc
WithWorkerQueueSizeOption has associated queue size at a worker.
func WithWorkerSizeOption ¶
func WithWorkerSizeOption(size int) OptionFunc
WithWorkerSizeOption has associated size for running workers.
func WithWorkerWaitInterval ¶
func WithWorkerWaitInterval(d time.Duration) OptionFunc
WithWorkerWaitInterval has associated wait time at a worker.
type StandardAction ¶
type StandardAction struct { Op ESOperation Index string DocType string Id string Doc map[string]interface{} }
StandardAction is a struct to implement an interface of Action.
func (*StandardAction) GetDoc ¶
func (da *StandardAction) GetDoc() map[string]interface{}
GetDoc returns value that should insert to a document on Elasticsearch.
func (*StandardAction) GetDocType ¶
func (da *StandardAction) GetDocType() string
GetDocType returns a doctype that want to insert on Elasticsearch.
func (*StandardAction) GetID ¶
func (da *StandardAction) GetID() string
GetID returns an id for document on Elasticsearch.
func (*StandardAction) GetIndex ¶
func (da *StandardAction) GetIndex() string
GetIndex returns an index that want to insert on Elasticsearch.
func (*StandardAction) GetOperation ¶
func (da *StandardAction) GetOperation() ESOperation
GetOperation returns an operation to process a document.