thoughtbot / griddler

Simplify receiving email in Rails (deprecated)
http://griddler.io/
MIT License
1.38k stars 199 forks source link

Griddler, Sidekiq as Processor #256

Closed bourg-ismael closed 8 years ago

bourg-ismael commented 8 years ago

Hi,

Is that possible to use Sidekiq to perform as Griddler Processor ? Currently Griddler return a Griddler Object that I can't send to Sidekiq, and I need it to upload attachments to S3 Bucket.

Do you have any way to use Griddler with Sidekiq ?

Thanks

bourg-ismael commented 8 years ago

I fixed it like that :

@email.attachments.each {|t| ObjectSpace.undefine_finalizer(t.tempfile)}

        # Griddler Email to hash for Sidekiq
        email = {
            attachments: @email.attachments.map {|att| {
                type: att.content_type,
                name: att.original_filename.include?('=?UTF-8?') ? "unknown#{Rack::Mime::MIME_TYPES.invert[att.content_type]}" : att.original_filename,
                path: att.tempfile.path
            }},
            raw_text: @email.raw_text,
            raw_html: @email.raw_html,
            from: @email.from,
            subject: @email.subject,
            to: @email.to,
            cc: @email.cc
        }

MessagesInboundWorker.perform_async email

Persisting my Tempfiles, then send it to my Worker

scott commented 8 years ago

Did you have to redefine the finalizer in your worker to ensure the tempfiles eventually get GC'd?