@CompileStatic class GparsAsyncSupport extends Object
a Gpars implementation of the AsyncSupport trait to be used for colating/slicing a list into "batches" to then asynchronously process with Transactions insert or update for maximum performance.
Type | Name and description |
---|---|
int |
poolSize the pool size passed to GParsPool.withPool. if gpars.poolsize is not set then it uses PoolUtils.retrieveDefaultPoolSize() |
Type Params | Return Type | Name and description |
---|---|---|
<T> |
Collection<T> |
eachParallel(Map args, Collection<T> collection, Closure itemClosure) Iterates over the batchList with GParsPoolUtil.eachParallel and calls the closure passing in the list and the args Uses withSession to make sure there is a session bound to the thread |
|
void |
init() setup defaults for poolSize and batchSize if config isn't present. batchSize set to 100 if not config found |
|
void |
parallel(Map args, List<List> batches, Closure batchClosure) Iterates over the batchList with GParsPoolUtil.eachParallel and calls the closure passing in the list and the args Generally you will want to use the AsyncSupport.parallel method that added by the Trait as it calls the withTransaction |
the pool size passed to GParsPool.withPool. if gpars.poolsize is not set then it uses PoolUtils.retrieveDefaultPoolSize()
Iterates over the batchList with GParsPoolUtil.eachParallel and calls the closure passing in the list and the args Uses withSession to make sure there is a session bound to the thread
args
- _optional_ arg map to be passed to the async engine such as gpars.
can also add any other value and they will be passed down through the closure as well collection
- a collated list of lists. each batch list in the batches will be asynchronously passed to the provided closureitemClosure
- the closure to call for each batch(sub-list of items) in the batches(list of batch sub-lists)setup defaults for poolSize and batchSize if config isn't present. batchSize set to 100 if not config found
Iterates over the batchList with GParsPoolUtil.eachParallel and calls the closure passing in the list and the args Generally you will want to use the AsyncSupport.parallel method that added by the Trait as it calls the withTransaction
args
- _optional_ arg map to be passed to the async engine such as gpars.
can also add any other value and they will be passed down through the closure as well batches
- a collated list of lists. each batch list in the batches will be asynchronously passed to the provided closurebatchClosure
- the closure to call for each batch(sub-list of items) in the batches(list of batch sub-lists)