-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback when finished processing #139
Comments
What backend are you using? |
I'm using sidekiq with redis |
I am marking this as a feature request. I will look into some solutions when I get a chance. |
Thanks. |
+1 on this; thinking about implementing a before_process_filter and after_process_filter |
+1 |
5 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
I will try and get this pushed this week... Thanks for all the feedback. |
I don't need it anymore. This worker will use |
+1 This would be totally useful. |
+1 |
Here's an initial pass at getting the callbacks working. Specs have been added and are passing. I have not manually tested this out, though, so it would be great if somebody could try it out. NOTE: This also comes with a change to the parameters for the "process_in_background" and "store_in_background" methods. process_in_background now looks like this: def process_in_background(column, options={}) The parameters are the same for store_in_background. The possible options are:
Example1: process_in_background(column, worker: ::CarrierWave::Workers::ProcessAsset) Example2: store_in_background(column, after_store: :do_something) If no worker is provided, the default worker for ProcessAsset or StoreAsset is used (as it did before). Callbacks only apply when using the default workers. |
+1 |
1 similar comment
+1 |
I have pulled in @mdurn's branch into branch https://github.com/lardawge/carrierwave_backgrounder/tree/add_callback_for_after_process and tested it. There was one fix that was needed but it is currently working with a custom worker. Have yet to test it with a callback. |
+1 |
If you need this feature and are unwilling to wait, the workaround is to create custom worker. class StreamUploadWorker < ::CarrierWave::Workers::ProcessAsset
def perform(*args)
set_args(*args) if args.present?
video = constantized_resource.find id
run_callback video, :before_upload
super(*args)
run_callback video, :after_upload_success
rescue
run_callback video, :after_upload_failure
Rails.logger.tagged 'StreamUploadWorker' do
Rails.logger.error "Error during uploading: #{$!.message}"
$!.backtrace.each { |line| Rails.logger.error line }
end
end
def run_callback(video, callback)
if video.respond_to?(callback)
Rails.logger.debug "Running callback: #{callback} for Video #{video.id}"
video.send(callback)
else
Rails.logger.debug "Unable to run callback: #{callback} for Video #{video.id}"
end
end
end |
+1 |
1 similar comment
+1 |
Hey I currently use store_in_background.
I need a callback which I can call as soon as all versions of a photo are created.
What's the best way to do this?
Regards,
Gambo
The text was updated successfully, but these errors were encountered: