es

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(s bandmaster.Service) *elastic.Client

Client returns the underlying `elastic.Client` of the given service.

It assumes that the service is ready; i.e. it might return nil if it's actually not.

NOTE: This will panic if `s` is not a `es.Service`.

func New

func New(conf *Config) bandmaster.Service

New creates a new ElasticSearch (v2) service using the provided configuration. You may use the helpers for environment-based configuration to get a pre-configured `Config` with sane defaults.

It doesn't open any connection nor does it do any kind of I/O; i.e. it cannot fail.

Types

type Config

type Config struct {
	Addr string
	Opts []elastic.ClientOptionFunc
}

Config contains the necessary configuration for an ElasticSearch (v5) service.

type Env

type Env struct {
	Addr string `envconfig:"ADDR" default:"http://localhost:9205"`
}

Env can be used to configure an ElasticSearch (v5) session via the environment.

It comes with sane defaults for a local development set-up.

func NewEnv

func NewEnv(prefix string) (*Env, error)

NewEnv parses the environment and returns a new `Env` structure.

`prefix` defines the prefix for the environment keys, e.g. with a 'XX' prefix, 'REPLICAS' would become 'XX_REPLICAS'.

func (*Env) Config

func (e *Env) Config() *Config

Config returns an ElasticSearch (v5) config using the values from the environment.

type Service

type Service struct {
	*bandmaster.ServiceBase // "inheritance"
	// contains filtered or unexported fields
}

Service implements an ElasticSearch (v5) service based on the 'olivere/elastic.v5' package.

func (*Service) Start

func (s *Service) Start(
	ctx context.Context, _ map[string]bandmaster.Service,
) error

Start opens a connection and pings the server: if everything goes smoothly, the service is marked as 'started'; otherwise, an error is returned.

The given context is forwarded to the elastic SDK.

Start is used by BandMaster's internal machinery, it shouldn't ever be called directly by the end-user of the service.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop closes the underlying `elastic.Client`: if everything goes smoothly, the service is marked as 'stopped'; otherwise, an error is returned.

Stop is used by BandMaster's internal machinery, it shouldn't ever be called directly by the end-user of the service.

Jump to

Keyboard shortcuts

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