Skip to content

Commit

Permalink
Job can read data from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
alindeman committed Feb 6, 2012
1 parent 15120b6 commit 4933b1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rector/job.rb
Expand Up @@ -28,19 +28,23 @@ def initialize
def id
# TODO: Obviously there's a small chance of jobs overlapping here
# Can do something more reliable for ID generation?
@id ||= SecureRandom.hex(8)
@id ||= SecureRandom.hex(10)
end

def allocate_worker_id
# TODO: Obviously there's a small chance of jobs overlapping here
# Can do something more reliable for ID generation?
"#{id}:#{SecureRandom.hex(10)}"
"#{id}:#{SecureRandom.hex(8)}"
end

def join
while @backend.workers_working?
sleep 5
end
end

def data
@data ||= @backend.read_job_data_to_hash
end
end
end
5 changes: 5 additions & 0 deletions spec/lib/job_spec.rb
Expand Up @@ -20,4 +20,9 @@
subject.join
end
end

it "loads data from the backend" do
backend.stubs(:read_job_data_to_hash).returns("foo" => "bar")
subject.data.should == { "foo" => "bar" }
end
end

0 comments on commit 4933b1d

Please sign in to comment.