elastigo
elastigo copied to clipboard
MAX_SHUTDOWN_SECS make me get into trouble
When I use BulkIndexer to index data into ElasticSearch, I find that sometimes it would lost some data, the reason is that before the program exit, I will call BulkIndexer.Stop() to make sure all work have completed, the documents said "Stop stops the bulk indexer, blocking the caller until it is complete.", however, there is the code :
// Stop stops the bulk indexer, blocking the caller until it is complete.
func (b *BulkIndexer) Stop() {
ch := make(chan struct{})
b.shutdownChan <- ch
select {
case <-ch:
// done
case <-time.After(time.Second * time.Duration(MAX_SHUTDOWN_SECS)):
// timeout!
}
}
It shows that if the caller have be blocking for more than MAX_SHUTDOWN_SECS
seconds, the Stop() will be timeout and return nothing.
BUT MAX_SHUTDOWN_SECS IS 5 SECONDS, some time it is not enough for me.
Is there any way to set up this value or know the timeout happend?
Thank you~