I want to send 1000 records at once in batchc of 500. Once they are sent then i want tail recursion to continue. numberOfEventsPerSecond=1000 putRecordLimit=500 sendInBatches is called before the furure call completes. Is there any way first the futureCall call is completed then only the sendInBatches is called.
@scala.annotation.tailrec
final def sendBatches(
buffer: Seq[File],
numberOfEventsPerSecond: Int
): Seq[PutRecordsRequestEntry] =
{
val (listToSend, remaining) = buffer.splitAt(numberOfEventsPerSecond)
val listRes = listToSend
.grouped(putRecordLimit)
.toList
.filter(_.nonEmpty)
listRes.map { list =>
futureCall(list.filter(_ != null)) map { putDataResult =>
println("Sent")
)
}
}
sendInBatches(fileOption, remaining, numberOfEventsPerSecond)
}