Class: GitMiner::Dispatch::ParallelDispatch

Inherits:
AbstractDispatch show all
Defined in:
lib/git_miner/dispatch/parallel_dispatch.rb

Defined Under Namespace

Classes: ShaFound

Constant Summary collapse

IDENTIFIER =
"Parallel"

Constants inherited from AbstractDispatch

AbstractDispatch::BATCH_SIZE

Instance Method Summary collapse

Methods inherited from AbstractDispatch

#execute, #initialize

Constructor Details

This class inherits a constructor from GitMiner::Dispatch::AbstractDispatch

Instance Method Details

#parallel_groupsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/git_miner/dispatch/parallel_dispatch.rb', line 35

def parallel_groups
  -> do
    author_offset = @group_manager.author_offset
    committer_offset = @group_manager.committer_offset

    @group_manager.advance!

    [
      author_offset,
      committer_offset
    ]
  end
end

#performObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/git_miner/dispatch/parallel_dispatch.rb', line 17

def perform
  Parallel.each(parallel_groups, in_processes: Concurrent.processor_count, preserve_results: false) do |group|
    author_offset, committer_offset = group

    result = @engine.mine(
      author_offset: author_offset,
      committer_offset: committer_offset,
      qty: @group_manager.batch_size
    )

    if result
      raise(ShaFound, result)
    end
  end
rescue ShaFound => e
  e.result
end