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 })
Example ¶
c := core.New(core.WithInline("log.level", "none")) c.ProvideEssentials() c.Provide(otes.Providers()) c.Invoke(func(esClient *elastic.Client) { running := esClient.IsRunning() fmt.Println(running) })
Output: true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Providers ¶
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
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 ¶
EsConfigInterceptor is an injector type hint that allows user to do last minute modification to es configurations.
type Factory ¶
Factory is a *di.Factory that creates *elastic.Client using a specific configuration entry.
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 ¶
NewTransport specifies a transport that will trace Elastic and report back via OpenTracing.