2011-06-21 08:22:45 -07:00
|
|
|
require 'resque-retry'
|
2012-11-04 10:01:03 -08:00
|
|
|
require 'timeout'
|
2011-06-21 08:22:45 -07:00
|
|
|
|
2011-05-20 16:19:14 -07:00
|
|
|
class AssetImageConversionRequest
|
2012-11-04 10:01:03 -08:00
|
|
|
TIMEOUT_IN_SECONDS = 30
|
|
|
|
|
2011-06-21 08:22:45 -07:00
|
|
|
extend Resque::Plugins::Retry
|
|
|
|
|
|
|
|
@retry_limit = 5
|
|
|
|
@retry_delay = 60
|
|
|
|
|
2011-05-20 16:19:14 -07:00
|
|
|
@queue = :requested_asset_images
|
|
|
|
|
2012-01-12 15:17:59 -08:00
|
|
|
def self.perform(asset_id)
|
2012-11-04 10:01:03 -08:00
|
|
|
Timeout::timeout(TIMEOUT_IN_SECONDS) do
|
|
|
|
asset = SwfAsset.find(asset_id)
|
|
|
|
asset.convert_swf_if_not_converted!
|
|
|
|
end
|
2011-05-20 16:19:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
class OnCreation < AssetImageConversionRequest
|
2011-06-21 08:22:45 -07:00
|
|
|
@retry_limit = 5
|
|
|
|
@retry_delay = 60
|
|
|
|
|
2011-05-20 16:19:14 -07:00
|
|
|
@queue = :requested_asset_images_on_creation
|
|
|
|
end
|
2011-08-07 15:23:44 -07:00
|
|
|
|
|
|
|
class OnBrokenImageReport < AssetImageConversionRequest
|
|
|
|
@retry_limit = 5
|
|
|
|
@retry_delay = 60
|
|
|
|
|
|
|
|
@queue = :reportedly_broken_asset_images
|
|
|
|
end
|
2011-05-20 16:19:14 -07:00
|
|
|
end
|
|
|
|
|