Class: Colore::Sidekiq::CallbackWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/sidekiq_workers.rb

Overview

This worker sends responses back to the client application.

Instance Method Summary collapse

Instance Method Details

#perform(doc_key_str, version, action, new_filename, callback_url, status, description) ⇒ Object

Constructs a conversion response and POSTs it to the specified callback_url.

Parameters:

  • doc_key_str (String)

    the serialised [DocKey]

  • version (String)

    the file version

  • action (String)

    the conversion to perform

  • new_filename (String)

    the converted file name

  • callback_url (String)

    callback URL

  • status (Integer)

    status code to send in callback

  • description (String)

    description text to send in callback


71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sidekiq_workers.rb', line 71

def perform doc_key_str, version, action, new_filename, callback_url, status, description
  doc_key = DocKey.parse doc_key_str
  doc = Document.load C_.storage_directory, doc_key
  rsp_hash = {
    status: status.to_i,
    description: description,
    app: doc_key.app,
    doc_id: doc_key.doc_id,
    version: version,
    action: action,
    path: (doc.file_path(version,new_filename) if status && status < 300),
  }
  RestClient.post callback_url, rsp_hash
end