init initializes the bulk indexer.
()
| 530 | |
| 531 | // init initializes the bulk indexer. |
| 532 | func (bi *bulkIndexer) init() { |
| 533 | for i := 1; i <= bi.config.NumWorkers; i++ { |
| 534 | bi.wg.Add(1) |
| 535 | w := worker{ |
| 536 | id: i, |
| 537 | ch: make(chan BulkIndexerItem, bi.config.QueueSizeMultiplier), |
| 538 | bi: bi, |
| 539 | buf: bytes.NewBuffer(make([]byte, 0, bi.config.FlushBytes)), |
| 540 | ticker: time.NewTicker(bi.nextFlushInterval()), |
| 541 | } |
| 542 | w.run() |
| 543 | bi.workers = append(bi.workers, &w) |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | // nextFlushInterval returns FlushInterval plus a random jitter in |
| 548 | // [0, FlushJitter) when FlushJitter > 0. Callers are independent worker |
no test coverage detected