Documentation
¶
Index ¶
- Constants
- func AssertOTelMetrics(t testing.TB, ms []metricdata.Metrics, assert func(m metricdata.Metrics))
- func DecodeBulkRequestWithStats(r *http.Request) (docs [][]byte, res BulkIndexerResponse, stats RequestStats)
- func DecodeBulkRequestWithStatsAndDynamicTemplates(r *http.Request) (docs [][]byte, res BulkIndexerResponse, stats RequestStats, ...)
- func DecodeBulkRequestWithStatsAndDynamicTemplatesAndPipelines(r *http.Request) (docs [][]byte, res BulkIndexerResponse, stats RequestStats, ...)
- func DecodeBulkRequestWithStatsAndMeta(r *http.Request) (docs [][]byte, meta []BulkRequestItemMeta, res BulkIndexerResponse, ...)
- func HandleBulk(mux *http.ServeMux, bulkHandler http.HandlerFunc)
- func NewAssertCounter(t testing.TB, asserted *atomic.Int64) func(metric metricdata.Metrics, count int64, attrs attribute.Set)
- func NewMockElasticsearchClient(t testing.TB, bulkHandler http.HandlerFunc) *elastictransport.Client
- func NewMockElasticsearchClientConfig(t testing.TB, bulkHandler http.HandlerFunc) elastictransport.Config
- type BulkIndexerResponse
- type BulkIndexerResponseItem
- type BulkRequestItemMeta
- type RequestStats
Constants ¶
const TimestampFormat = "2006-01-02T15:04:05.000Z07:00"
TimestampFormat holds the time format for formatting timestamps according to Elasticsearch's strict_date_optional_time date format, which includes a fractional seconds component.
Variables ¶
This section is empty.
Functions ¶
func AssertOTelMetrics ¶
func AssertOTelMetrics(t testing.TB, ms []metricdata.Metrics, assert func(m metricdata.Metrics))
AssertOTelMetrics asserts OTel metrics using a closure.
func DecodeBulkRequestWithStats ¶ added in v2.1.0
func DecodeBulkRequestWithStats(r *http.Request) ( docs [][]byte, res BulkIndexerResponse, stats RequestStats)
DecodeBulkRequestWithStats decodes a /_bulk request's body, returning the decoded documents and a response body and stats about request.
func DecodeBulkRequestWithStatsAndDynamicTemplates ¶ added in v2.3.0
func DecodeBulkRequestWithStatsAndDynamicTemplates(r *http.Request) ( docs [][]byte, res BulkIndexerResponse, stats RequestStats, dynamicTemplates []map[string]string)
DecodeBulkRequestWithStatsAndDynamicTemplates decodes a /_bulk request's body, returning the decoded documents and a response body and stats about request, and per-request dynamic templates.
func DecodeBulkRequestWithStatsAndDynamicTemplatesAndPipelines ¶ added in v2.4.0
func DecodeBulkRequestWithStatsAndDynamicTemplatesAndPipelines(r *http.Request) ( docs [][]byte, res BulkIndexerResponse, stats RequestStats, dynamicTemplates []map[string]string, pipelines []string, )
DecodeBulkRequestWithStatsAndDynamicTemplatesAndPipelines decodes a /_bulk request's body, returning the decoded documents and a response body and stats about request, per-request dynamic templates and pipelines specified in the event.
func DecodeBulkRequestWithStatsAndMeta ¶ added in v2.6.0
func DecodeBulkRequestWithStatsAndMeta(r *http.Request) ( docs [][]byte, meta []BulkRequestItemMeta, res BulkIndexerResponse, stats RequestStats, )
DecodeBulkRequestWithStatsAndMeta decodes a /_bulk request's body, returning the decoded bulk request action/meta and documents, and a response body and stats about the request.
func HandleBulk ¶
func HandleBulk(mux *http.ServeMux, bulkHandler http.HandlerFunc)
HandleBulk registers bulkHandler with mux for handling /_bulk requests, wrapping bulkHandler to conform with go-elasticsearch version checking.
func NewAssertCounter ¶
func NewAssertCounter(t testing.TB, asserted *atomic.Int64) func(metric metricdata.Metrics, count int64, attrs attribute.Set)
NewAssertCounter returns a function that canbe used to assert counter metrics
func NewMockElasticsearchClient ¶
func NewMockElasticsearchClient(t testing.TB, bulkHandler http.HandlerFunc) *elastictransport.Client
NewMockElasticsearchClient returns an elasticsearch.Client which sends /_bulk requests to bulkHandler.
func NewMockElasticsearchClientConfig ¶
func NewMockElasticsearchClientConfig(t testing.TB, bulkHandler http.HandlerFunc) elastictransport.Config
NewMockElasticsearchClientConfig starts an httptest.Server, and returns an elasticsearch.Config which sends /_bulk requests to bulkHandler. The httptest.Server will be closed via t.Cleanup.
Types ¶
type BulkIndexerResponse ¶ added in v2.7.0
type BulkIndexerResponse struct {
Took int `json:"took"`
HasErrors bool `json:"errors"`
Items []map[string]BulkIndexerResponseItem `json:"items,omitempty"`
}
func DecodeBulkRequest ¶
func DecodeBulkRequest(r *http.Request) ([][]byte, BulkIndexerResponse)
DecodeBulkRequest decodes a /_bulk request's body, returning the decoded documents and a response body.
type BulkIndexerResponseItem ¶ added in v2.7.0
type BulkIndexerResponseItem struct {
Index string `json:"_index"`
DocumentID string `json:"_id"`
Version int64 `json:"_version"`
Result string `json:"result"`
Status int `json:"status"`
SeqNo int64 `json:"_seq_no"`
PrimTerm int64 `json:"_primary_term"`
FailureStore string `json:"failure_store,omitempty"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_shards"`
Error struct {
Type string `json:"type"`
Reason string `json:"reason"`
Cause struct {
Type string `json:"type"`
Reason string `json:"reason"`
} `json:"caused_by"`
} `json:"error,omitempty"`
}
BulkIndexerResponseItem represents the Elasticsearch response item.