require "celluloid"
class MonthlyRecordWorker
include Celluloid
def update_record(idrecord)
recordupdated_record = RecordBaseAmountService.build.call(record, record.subrecord)
recordupdated_record.save
end
end
class MonthlyTaskService
def call
record_pool = MonthlyRecordWorker.pool(size: 10)
Record.all.each do |i|
record_pool.async.update_record(i.id)
end
end
end
#lib/tasks/monthly.rake
namespace :monthly do
desc "Cron tasks"
task :audit_records => :environment do
MonthlyTaskService.build.call
end
end