api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v1.0.0

func Close(ctx context.Context) error

Close represents the graceful shutting down of the http server

func CreateAndInitialise added in v1.0.0

func CreateAndInitialise(bindAddr string, elasticSearchClient ElasticSearcher, errorChan chan error) error

CreateAndInitialise initiates a new Search Query API

func DataLookupHandlerFunc added in v1.0.0

func DataLookupHandlerFunc(elasticSearchClient ElasticSearcher) http.HandlerFunc

DataLookupHandlerFunc returns a http handler function handling search api requests.

func HealthCheckHandlerCreator added in v1.0.0

func HealthCheckHandlerCreator() func(http.ResponseWriter, *http.Request)

func SearchHandlerFunc

func SearchHandlerFunc(elasticSearchClient ElasticSearcher) http.HandlerFunc

SearchHandlerFunc returns a http handler function handling search api requests.

func SetupData added in v1.0.0

func SetupData() error

SetupTimeseries loads templates for use by the timeseries lookup handler and should be done only once

func SetupSearch added in v1.0.0

func SetupSearch() error

SetupSearch loads templates for use by the search handler and should be done only once

func SetupTimeseries added in v1.0.0

func SetupTimeseries() error

SetupTimeseries loads templates for use by the timeseries lookup handler and should be done only once

func TimeseriesLookupHandlerFunc added in v1.0.0

func TimeseriesLookupHandlerFunc(elasticSearchClient ElasticSearcher) http.HandlerFunc

TimeseriesLookupHandlerFunc returns a http handler function handling search api requests.

Types

type ElasticSearcher

type ElasticSearcher interface {
	Search(index string, docType string, request []byte) ([]byte, error)
	MultiSearch(index string, docType string, request []byte) ([]byte, error)
}

ElasticSearcher provides client methods for the elasticsearch package

type ElasticSearcherMock

type ElasticSearcherMock struct {
	// MultiSearchFunc mocks the MultiSearch method.
	MultiSearchFunc func(index string, docType string, request []byte) ([]byte, error)

	// SearchFunc mocks the Search method.
	SearchFunc func(index string, docType string, request []byte) ([]byte, error)
	// contains filtered or unexported fields
}

ElasticSearcherMock is a mock implementation of ElasticSearcher.

    func TestSomethingThatUsesElasticSearcher(t *testing.T) {

        // make and configure a mocked ElasticSearcher
        mockedElasticSearcher := &ElasticSearcherMock{
            MultiSearchFunc: func(index string, docType string, request []byte) ([]byte, error) {
	               panic("mock out the MultiSearch method")
            },
            SearchFunc: func(index string, docType string, request []byte) ([]byte, error) {
	               panic("mock out the Search method")
            },
        }

        // use mockedElasticSearcher in code that requires ElasticSearcher
        // and then make assertions.

    }

func (*ElasticSearcherMock) MultiSearch

func (mock *ElasticSearcherMock) MultiSearch(index string, docType string, request []byte) ([]byte, error)

MultiSearch calls MultiSearchFunc.

func (*ElasticSearcherMock) MultiSearchCalls

func (mock *ElasticSearcherMock) MultiSearchCalls() []struct {
	Index   string
	DocType string
	Request []byte
}

MultiSearchCalls gets all the calls that were made to MultiSearch. Check the length with:

len(mockedElasticSearcher.MultiSearchCalls())

func (*ElasticSearcherMock) Search

func (mock *ElasticSearcherMock) Search(index string, docType string, request []byte) ([]byte, error)

Search calls SearchFunc.

func (*ElasticSearcherMock) SearchCalls

func (mock *ElasticSearcherMock) SearchCalls() []struct {
	Index   string
	DocType string
	Request []byte
}

SearchCalls gets all the calls that were made to Search. Check the length with:

len(mockedElasticSearcher.SearchCalls())

type SearchQueryAPI added in v1.0.0

type SearchQueryAPI struct {
	Router        *mux.Router
	ElasticSearch ElasticSearcher
}

SearchQueryAPI provides an API around elasticseach

func NewSearchQueryAPI added in v1.0.0

func NewSearchQueryAPI(router *mux.Router, elasticSearch ElasticSearcher) *SearchQueryAPI

NewSearchQueryAPI returns a new Search Query API struct after registering the routes

Jump to

Keyboard shortcuts

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