Class: Gitlab::PhabricatorImport::WorkerState
- Inherits:
-
Object
- Object
- Gitlab::PhabricatorImport::WorkerState
- Defined in:
- lib/gitlab/phabricator_import/worker_state.rb
Instance Method Summary collapse
- #add_job ⇒ Object
-
#initialize(project_id) ⇒ WorkerState
constructor
A new instance of WorkerState.
- #remove_job ⇒ Object
- #running_count ⇒ Object
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_job ⇒ Object
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_job ⇒ Object
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_count ⇒ Object
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 |