diff --git a/modules/joex/src/main/resources/reference.conf b/modules/joex/src/main/resources/reference.conf index a9b76e71..1958070b 100644 --- a/modules/joex/src/main/resources/reference.conf +++ b/modules/joex/src/main/resources/reference.conf @@ -106,14 +106,18 @@ docspell.joex { max-folders = 50 # How many mails (headers only) to retrieve in one chunk. - mail-chunk-size = 100 + # + # If this is greater than `max-mails' it is set automatically to + # the value of `max-mails'. + mail-chunk-size = 50 # A limit on how many mails to process in one job run. This is - # only to avoid resource allocation to one user/collective. + # meant to avoid too heavy resource allocation to one + # user/collective. # # If more than this number of mails is encountered, a warning is # logged. - max-mails = 1000 + max-mails = 500 } } diff --git a/modules/joex/src/main/scala/docspell/joex/Config.scala b/modules/joex/src/main/scala/docspell/joex/Config.scala index 7292e5f9..27817d69 100644 --- a/modules/joex/src/main/scala/docspell/joex/Config.scala +++ b/modules/joex/src/main/scala/docspell/joex/Config.scala @@ -29,6 +29,9 @@ case class Config( object Config { case class Bind(address: String, port: Int) - case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) + case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) { + def mailBatchSize: Int = + math.min(mailChunkSize, maxMails) + } case class UserTasks(scanMailbox: ScanMailbox) } diff --git a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala index 8af6b6a7..670b2fec 100644 --- a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala @@ -164,11 +164,11 @@ object ScanMailboxTask { for { _ <- Kleisli.liftF( ctx.logger.debug( - s"Searching next ${cfg.mailChunkSize} mails in ${folder.name}." + s"Searching next ${cfg.mailBatchSize} mails in ${folder.name}." ) ) query <- Kleisli.liftF(q) - mails <- a.search(folder, cfg.mailChunkSize)(query) + mails <- a.search(folder, cfg.mailBatchSize)(query) _ <- Kleisli.liftF( ctx.logger.debug( s"Found ${mails.count} mails in folder. Reading first ${mails.mails.size}"