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

Function main

_examples/configuration.go:31–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29)
30
31func main() {
32 log.SetFlags(0)
33
34 // This example demonstrates how to configure the client's Transport.
35 //
36 // NOTE: These values are for illustrative purposes only, and not suitable
37 // for any production use. The default transport is sufficient.
38 //
39 es, err := elasticsearch.New(
40 elasticsearch.WithAddresses("http://localhost:9200"),
41 elasticsearch.WithTransportOptions(
42 elastictransport.WithTransport(&http.Transport{
43 MaxIdleConnsPerHost: 10,
44 ResponseHeaderTimeout: time.Millisecond,
45 DialContext: (&net.Dialer{Timeout: time.Nanosecond}).DialContext,
46 TLSClientConfig: &tls.Config{
47 MinVersion: tls.VersionTLS12,
48 // ...
49 },
50 }),
51 ),
52 )
53 if err != nil {
54 log.Printf("Error creating the client: %s", err)
55 } else {
56 log.Println(es.Info())
57 // => dial tcp: i/o timeout
58 }
59}

Callers

nothing calls this directly

Calls 2

PrintfMethod · 0.80
InfoMethod · 0.45

Tested by

no test coverage detected