| 72 | } |
| 73 | |
| 74 | func main() { |
| 75 | var wg sync.WaitGroup |
| 76 | |
| 77 | // Create the custom transport. |
| 78 | // |
| 79 | tp := CountingTransport{} |
| 80 | |
| 81 | // Pass the custom transport to the client. |
| 82 | // |
| 83 | es, _ := elasticsearch.New( |
| 84 | elasticsearch.WithTransportOptions(elastictransport.WithTransport(&tp)), |
| 85 | ) |
| 86 | |
| 87 | for i := 0; i < 25; i++ { |
| 88 | wg.Add(1) |
| 89 | go func() { |
| 90 | defer wg.Done() |
| 91 | es.Info() |
| 92 | }() |
| 93 | } |
| 94 | wg.Wait() |
| 95 | |
| 96 | fmt.Println(strings.Repeat("=", 80)) |
| 97 | fmt.Printf("%80s\n", fmt.Sprintf("Total Requests: %d", atomic.LoadUint64(&tp.count))) |
| 98 | } |