Sha256: f062b508868b3dbb1618499687657dbdf97ae27374ca9dc83b1f17d487261bb2

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

module Tennis
  module Backend
    class Task

      attr_reader :task_id, :job, :method, :args, :meta
      attr_accessor :worker

      def initialize(backend, task_id, job, method, args, meta = {})
        @backend, @task_id, @acked = backend, task_id, false
        @job, @method, @args = job, method, args
        @meta = meta
      end

      def execute
        @job.__send__(@method, *@args)
      end

      def ack
        return if acked?
        @backend.ack(self)
        @acked = true
      end

      def requeue
        return if acked?
        @backend.requeue(self)
        @acked = true
      end

      def acked?
        @acked
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tennis-jobs-0.4.0 lib/tennis/backend/task.rb