Class: Legate::Tools::SleepyTool

Inherits:
BaseAsyncJobTool show all
Defined in:
lib/legate/tools/sleepy_tool.rb

Overview

An example Legate tool that starts a background job that sleeps for a specified duration. This tool demonstrates how to implement a BaseAsyncJobTool with a background worker.

Instance Attribute Summary

Attributes inherited from Legate::Tool

#description, #name, #parameters

Instance Method Summary collapse

Methods inherited from BaseAsyncJobTool

job_results, store_job_error, store_job_pending, store_job_result

Methods inherited from Legate::Tool

define_metadata, #execute, inherited, #initialize, #validate_and_coerce_params, #validate_params

Methods included from Legate::Tool::MetadataDsl

included

Constructor Details

This class inherits a constructor from Legate::Tool

Instance Method Details

#prepare_job_arguments(params, _context) ⇒ Object

Prepare the arguments for the worker’s perform method. Arguments must be JSON-serializable.



35
36
37
38
39
# File 'lib/legate/tools/sleepy_tool.rb', line 35

def prepare_job_arguments(params, _context)
  duration = params[:duration].to_i
  message = params[:message].to_s
  [duration, message] # Must match SleepyWorker#perform signature (after jid)
end

#worker_classObject

Return the worker class to use.



29
30
31
# File 'lib/legate/tools/sleepy_tool.rb', line 29

def worker_class
  SleepyWorker
end