Sha256: 7bb1e4207e9c4172f69142b4634f2c23f17aaf054dea8242c4fc7770220be427

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'pg'

class SomeException < RuntimeError
end

class SomeOtherException < RuntimeError
end

module Jobs
  module Tests
    class LockedTestJob < QueueClassicPlus::Base
      lock!

      @queue = :low
      retry! on: SomeException, max: 5

      def self.perform should_raise
        raise SomeException if should_raise
      end
    end


    class TestJobNoRetry < QueueClassicPlus::Base
      class Custom < RuntimeError
      end
      disable_retries!

      @queue = :low

      def self.perform should_raise
        raise Custom if should_raise
      end
    end


    class TestJob < QueueClassicPlus::Base
      @queue = :low
      retry! on: SomeException, max: 5

      def self.perform should_raise
        raise SomeException if should_raise
      end
    end

    class Exception < RuntimeError
      attr_reader :original_exception

      def initialize(e)
        @original_exception = e
      end
    end

    class ConnectionReapedTestJob < QueueClassicPlus::Base
      @queue = :low
      retry! on: Exception, max: 5

      def self.perform
        raise Exception.new(PG::UnableToSend.new)
      end
    end

    class UniqueViolationTestJob < QueueClassicPlus::Base
      @queue = :low

      def self.perform
        raise Exception.new(PG::UniqueViolation.new)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
queue_classic_plus-1.0.0 spec/sample_jobs.rb