Sha256: aef4d29de0eca72be5685c567d1df66f416a7bd9f0a90742121c0161f66e190b
Contents?: true
Size: 1.44 KB
Versions: 8
Compression:
Stored size: 1.44 KB
Contents
module Marty module Promises module Ruby module Create def self.call(module_name:, method_name:, method_args:, params: {}) default_timeout = Marty::Promise::DEFAULT_PROMISE_TIMEOUT promise_params = params.with_indifferent_access title = promise_params['p_title'] || "#{module_name}.#{method_name}" timeout = promise_params['p_timeout'] || default_timeout hook = promise_params['p_hook'] promise = Marty::Promise.create( title: title, user_id: promise_params[:_user_id], parent_id: promise_params[:_parent_id], promise_type: 'ruby' ) begin promise_job = Marty::PromiseRubyJob.new( promise, title, module_name, method_name, method_args, hook ) job = Delayed::Job.enqueue(promise_job) rescue StandardError => e res = { 'error' => e.message } promise.set_start promise.set_result(res) raise end # keep a reference to the job. This is needed in case we want to # work off a promise job that we're waiting for and which hasn't # been reserved yet. promise.job_id = job.id promise.save! Marty::PromiseProxy.new(promise.id, timeout, 'result') end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems