MCPcopy
hub / github.com/elastic/go-elasticsearch / init

Function init

_benchmarks/benchmarks/actions/006_bulk_helper.go:36–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34)
35
36func init() {
37 benchmarks.Register(
38 benchmarks.Action{
39 Name: "bulk-helper",
40 Category: "helpers",
41
42 NumWarmups: 1,
43 NumRepetitions: 10,
44 NumOperations: 1000000,
45
46 SetupFunc: func(n int, c runner.Config) (*esapi.Response, error) {
47 var (
48 res *esapi.Response
49 err error
50
51 indexName = "test-bench-bulk-helper"
52 indexSettings = `{"settings": { "number_of_shards": 3, "refresh_interval":"5s"}}`
53 )
54 res, _ = c.RunnerClient.Indices.Delete([]string{indexName})
55 if res != nil && res.Body != nil {
56 res.Body.Close()
57 }
58 res, err = c.RunnerClient.Indices.Create(
59 indexName,
60 c.RunnerClient.Indices.Create.WithBody(strings.NewReader(indexSettings)),
61 c.RunnerClient.Indices.Create.WithWaitForActiveShards("1"))
62 if err != nil {
63 return res, err
64 }
65 if res != nil && res.Body != nil {
66 res.Body.Close()
67 }
68 return res, err
69 },
70
71 RunnerFunc: func(n int, c runner.Config) (*esapi.Response, error) {
72 var (
73 err error
74
75 indexName = "test-bench-bulk-helper"
76 )
77
78 var addresses []string
79 for _, u := range c.RunnerClient.Transport.(*elastictransport.Client).URLs() {
80 addresses = append(addresses, u.String())
81 }
82
83 es, err := elasticsearch.New(
84 elasticsearch.WithAddresses(addresses...),
85 elasticsearch.WithRetry(5, 502, 503, 504, 429),
86 )
87 if err != nil {
88 return nil, err
89 }
90
91 bi, err := esutil.NewBulkIndexer(esutil.BulkIndexerConfig{
92 Index: indexName,
93 Client: es,

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
AddMethod · 0.95
StatsMethod · 0.95
NewBulkIndexerFunction · 0.92
DeleteMethod · 0.45
CreateMethod · 0.45
WithBodyMethod · 0.45
StringMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected