Class: Employer::Pipeline
- Inherits:
-
Object
- Object
- Employer::Pipeline
- Defined in:
- lib/employer/pipeline.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #backend ⇒ Object
- #backend=(backend) ⇒ Object
- #clear ⇒ Object
- #complete(job) ⇒ Object
- #dequeue ⇒ Object
- #enqueue(job) ⇒ Object
- #fail(job) ⇒ Object
-
#initialize(logger) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #reset(job) ⇒ Object
Constructor Details
#initialize(logger) ⇒ Pipeline
Returns a new instance of Pipeline.
7 8 9 |
# File 'lib/employer/pipeline.rb', line 7 def initialize(logger) @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/employer/pipeline.rb', line 5 def logger @logger end |
Instance Method Details
#backend ⇒ Object
15 16 17 |
# File 'lib/employer/pipeline.rb', line 15 def backend @backend end |
#backend=(backend) ⇒ Object
11 12 13 |
# File 'lib/employer/pipeline.rb', line 11 def backend=(backend) @backend = backend end |
#clear ⇒ Object
33 34 35 36 37 |
# File 'lib/employer/pipeline.rb', line 33 def clear raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Clearing pipeline of all jobs!") backend.clear end |
#complete(job) ⇒ Object
39 40 41 42 43 |
# File 'lib/employer/pipeline.rb', line 39 def complete(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Marking job #{job.id} as complete") backend.complete(job) end |
#dequeue ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/employer/pipeline.rb', line 25 def dequeue raise Employer::Errors::PipelineBackendRequired if backend.nil? if serialized_job = backend.dequeue job_class = constantize(serialized_job[:class]) job_class.deserialize(serialized_job) end end |
#enqueue(job) ⇒ Object
19 20 21 22 23 |
# File 'lib/employer/pipeline.rb', line 19 def enqueue(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? serialized_job = job.serialize backend.enqueue(serialized_job) end |
#fail(job) ⇒ Object
51 52 53 54 55 |
# File 'lib/employer/pipeline.rb', line 51 def fail(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Marking job #{job.id} as failed") backend.fail(job) end |
#reset(job) ⇒ Object
45 46 47 48 49 |
# File 'lib/employer/pipeline.rb', line 45 def reset(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Resetting job #{job.id}") backend.reset(job) end |