lib/qpush/server/jobs.rb in qpush-0.1.7 vs lib/qpush/server/jobs.rb in qpush-0.1.8

- old
+ new

@@ -5,16 +5,23 @@ def included(base) _register_job(base) end def _register_job(base) - Server.redis { |c| c.sadd(QPush::Base::KEY + ':jobs', base.name) } + Server.redis { |c| c.sadd("#{QPush::Base::KEY}:jobs", base.name) } end end end - module JobHelpers + class Job < QPush::Base::Job + include QPush::Server::ApiWrapper + include ObjectValidator::Validate + + def initialize(options) + super + end + def mark_success @failed = false @total_success += 1 end @@ -54,25 +61,9 @@ end def retry_at Time.now.to_i + ((@total_fail**4) + 15 + (rand(30) * (@total_fail + 1))) end - end - - class Job < QPush::Base::Job - extend Forwardable - - include QPush::Server::JobHelpers - include ObjectValidator::Validate - - - def initialize(options) - super - @api = ApiWrapper.new(self) - end - - def_delegators :@api, :queue, :execute, :perform, - :delay, :retry, :morgue, :setup end class JobValidator include ObjectValidator::Validator