Class: GitMiner::Dispatch::AbstractDispatch

Inherits:
Object
  • Object
show all
Defined in:
lib/git_miner/dispatch/abstract_dispatch.rb

Direct Known Subclasses

ParallelDispatch, SimpleDispatch

Constant Summary collapse

IDENTIFIER =
"N/A"
BATCH_SIZE =
50_000

Instance Method Summary collapse

Constructor Details

#initialize(prefix:, engine:) ⇒ AbstractDispatch

Returns a new instance of AbstractDispatch.



8
9
10
11
12
13
# File 'lib/git_miner/dispatch/abstract_dispatch.rb', line 8

def initialize(prefix:, engine:)
  @prefix = prefix
  @engine = engine

  @group_manager = GroupManager.new(batch_size: BATCH_SIZE)
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/git_miner/dispatch/abstract_dispatch.rb', line 15

def execute
  thread = Thread.new do
    progress = Progress.new(@prefix.length)
    loop do
      progress.tick(@group_manager.batch, @group_manager.count)
      sleep 1
    end
  end

  perform
ensure
  thread.kill
end