docappendertest

package
v2.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
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.

type BulkRequestItemMeta added in v2.6.0

type BulkRequestItemMeta struct {
	Action            string            `json:"-"`
	Index             string            `json:"_index"`
	DocumentID        string            `json:"_id"`
	Pipeline          string            `json:"pipeline"`
	DynamicTemplates  map[string]string `json:"dynamic_templates"`
	RequireDataStream bool              `json:"require_data_stream"`
}

type RequestStats added in v2.1.0

type RequestStats struct {
	UncompressedBytes int64
	EventCount        int64
}

Jump to

Keyboard shortcuts

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