otes

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package otes provides es client with opentracing. For documentation about es usage, see https://github.com/olivere/elastic

Integration

package otes exports the configuration in the following format:

	es:
	  default:
        "url": "http://localhost:9200"
		"index":       "",
		"username":    "",
		"password":    "",
		"shards":      0,
		"replicas":    0,
		"sniff":       false,
		"healthCheck": false,

Add the es dependency to core:

var c *core.C = core.New()
c.Provide(otes.Providers())

Then you can invoke etcd from the application.

c.Invoke(func(client *elastic.Client) {
	// Do something with es
})

Sometimes there are valid reasons to connect to more than one es server. Inject otes.Maker to factory a *elastic.Client with a specific configuration entry.

c.Invoke(function(maker otes.Maker) {
	client, err := maker.Make("default")
	// do something with client
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Providers

func Providers() di.Deps

Providers returns a set of dependency providers. It includes the Maker, the default *elastic.Client and exported configs.

Depends On:
	log.Logger
	contract.ConfigAccessor
	EsConfigInterceptor `optional:"true"`
	opentracing.Tracer     `optional:"true"`
Provides:
	Factory
	Maker
	*elastic.Client

Types

type Config added in v0.4.1

type Config struct {
	URL         []string `json:"url" yaml:"url"`
	Index       string   `json:"index" yaml:"index"`
	Username    string   `json:"username" yaml:"username"`
	Password    string   `json:"password" yaml:"password"`
	Shards      int      `json:"shards" yaml:"shards"`
	Replicas    int      `json:"replicas" yaml:"replicas"`
	Sniff       *bool    `json:"sniff" yaml:"sniff"`
	Healthcheck *bool    `json:"healthcheck" yaml:"healthcheck"`
}

Config is the type of elasticsearch configurations.

type ElasticLogAdapter added in v0.4.2

type ElasticLogAdapter struct {
	Logging log.Logger
}

ElasticLogAdapter is an adapter between kitlog and elastic logger interface

func (ElasticLogAdapter) Printf added in v0.4.2

func (l ElasticLogAdapter) Printf(msg string, v ...interface{})

Printf implements elastic.Logger

type EsConfigInterceptor

type EsConfigInterceptor func(name string, opt *Config)

EsConfigInterceptor is an injector type hint that allows user to do last minute modification to es configurations.

type Factory

type Factory struct {
	*di.Factory
}

Factory is a *di.Factory that creates *elastic.Client using a specific configuration entry.

func (Factory) Make

func (r Factory) Make(name string) (*elastic.Client, error)

Make creates *elastic.Client using a specific configuration entry.

type Maker

type Maker interface {
	Make(name string) (*elastic.Client, error)
}

Maker models Factory

type Option

type Option func(t *Transport)

Option signature for specifying options, e.g. WithRoundTripper.

func WithRoundTripper

func WithRoundTripper(rt http.RoundTripper) Option

WithRoundTripper specifies the http.RoundTripper to call next after this transport. If it is nil (default), the transport will use http.DefaultTransport.

func WithTracer

func WithTracer(tracer opentracing.Tracer) Option

WithTracer specifies the opentracing.Tracer to call this transport.

type Transport

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

Transport for tracing Elastic operations.

func NewTransport

func NewTransport(opts ...Option) *Transport

NewTransport specifies a transport that will trace Elastic and report back via OpenTracing.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip captures the request and starts an OpenTracing span for Elastic PerformRequest operation.

Jump to

Keyboard shortcuts

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