lib/isono/node_modules/job_channel.rb
# Send a new job request and wait until the job finished.
# The difference to submit() is that this method will stop the
# thread until the called job completed.
#
# @param [String] endpoint endpoint name created by JobChannel#register_endpoint()
# @param [String] command command name in the endpoint.
# @param [any] *args arguments to run the job.
# @yieldparam [RpcChannel::RequestContext] modify RPC request before sending. The
#   method will stop the current thread if it does not exist.
# 
# @example wait while the job running.
#   run('endpoint1', 'command1', 1, 2, 3) #=> result of 'endpoint1/command1'.
# @example receive progress messages from long running job.
#   run('endpoint1', 'command1', 1, 2, 3) do |req|
#      req.on_progress { |r|
#        puts r #=> show progress message
#      }
#   end
Send a new job request and wait until the job finished.
The difference to submit() is that this method will stop the
thread until the called job completed.
Send a new job request and wait until the job finished . The difference to submit () is that this method will stop the thread until the called job completed .
def run(endpoint, command, *args, &blk)
        cur_job_ctx = Thread.current[JobWorker::JOB_CTX_KEY]
        req = rpc.request("job.#{endpoint}", command, *args) { |req|
          req.timeout_sec = config_section.timeout_sec
          req.request[:job_id] = Util.gen_id
          req.request[:session_id] = req.request[:job_id]
          req.request[:job_name] = command
          if cur_job_ctx
            req.request[:parent_job_id] = cur_job_ctx.job_id
            req.request[:session_id] = cur_job_ctx.session_id
          end
          blk ? blk.call(req) : req.synchronize
        }
        blk ? req : req.wait
      end
def run ( endpoint , command , * args , & blk ) cur_job_ctx = Thread . current [ JobWorker :: JOB_CTX_KEY ] req = rpc . request ( "job.#{endpoint}" , command , * args ) { | req | req . timeout_sec = config_section . timeout_sec req . request [ :job_id ] = Util . gen_id req . request [ :session_id ] = req . request [ :job_id ] req . request [ :job_name ] = command if cur_job_ctx req . request [ :parent_job_id ] = cur_job_ctx . job_id req . request [ :session_id ] = cur_job_ctx . session_id end blk ? blk . call ( req ) : req . synchronize } blk ? req : req . wait end
Send a new job request and wait until the job finished.
Send a new job request and wait until the job finished .
# A job is working on this current thread if cur_job_ctx is # not nil. Let the new job know the current job ID # as its parent job ID.
endpoint
command
args
blk
modify RPC request before sending. The method will stop the current thread if it does not exist.
modify RPC request before sending . The method will stop the current thread if it does not exist .
example
wait while the job running.
wait while the job running .
example
receive progress messages from long running job. run('endpoint1', 'command1', 1, 2, 3) do |req| req.on_progress { |r| puts r #=> show progress message } end
receive progress messages from long running job . run ( ' endpoint1 ' ' command1 ' 1 2 3 ) do |req| req . on_progress { |r| puts r # = > show progress message } end