Class: Gitlab::PhabricatorImport::WorkerState

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/phabricator_import/worker_state.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_id) ⇒ WorkerState

Returns a new instance of WorkerState.


5
6
7
# File 'lib/gitlab/phabricator_import/worker_state.rb', line 5

def initialize(project_id)
  @project_id = project_id
end

Instance Method Details

#add_jobObject


9
10
11
12
13
14
15
16
# File 'lib/gitlab/phabricator_import/worker_state.rb', line 9

def add_job
  redis.with do |r|
    r.pipelined do |pipe|
      pipe.incr(all_jobs_key)
      pipe.expire(all_jobs_key, timeout)
    end
  end
end

#remove_jobObject


18
19
20
21
22
# File 'lib/gitlab/phabricator_import/worker_state.rb', line 18

def remove_job
  redis.with do |r|
    r.decr(all_jobs_key)
  end
end

#running_countObject


24
25
26
# File 'lib/gitlab/phabricator_import/worker_state.rb', line 24

def running_count
  redis.with { |r| r.get(all_jobs_key) }.to_i
end