lib/gladys/actions/prepare.rb



# frozen_string_literal: true

module Gladys
  module Actions
    class Prepare < Base
      Report = Struct.new(:database_size)

      def run(threads:)
        invoke(:prepare, threads: threads, should_stop: -> { database_size_reached? })
      end

      def report
        Report.new(database_size: current_database_size)
      end

      private

      def database_size_reached?
        db_size = current_database_size
        Gladys.log_debug "Checking if database size reached #{@context.options.database_size}..."
        Gladys.log_debug "Current database size: #{db_size}"

        db_size >= @context.options.database_size
      end
    end
  end
end