crew_class_launcher | R Documentation |
R6
abstract class to build other subclasses
which launch and manage workers.
name
See crew_launcher()
.
workers
See crew_launcher()
.
seconds_interval
See crew_launcher()
.
seconds_timeout
See crew_launcher()
.
seconds_launch
See crew_launcher()
.
seconds_idle
See crew_launcher()
.
seconds_wall
See crew_launcher()
.
tasks_max
See crew_launcher()
.
tasks_timers
See crew_launcher()
.
reset_globals
See crew_launcher()
.
reset_packages
See crew_launcher()
.
reset_options
See crew_launcher()
.
garbage_collection
See crew_launcher()
.
tls
See crew_launcher()
.
processes
See crew_launcher()
.
asynchronously.
r_arguments
See crew_launcher()
.
options_metrics
See crew_launcher()
.
url
Websocket URL for worker connections.
profile
mirai
compute profile of the launcher.
instances
Data frame of worker instance information.
id
Integer worker ID from the last call to settings()
.
async
A crew_async()
object to run low-level launcher tasks
asynchronously.
throttle
A crew_throttle()
object to throttle scaling.
new()
Launcher constructor.
crew_class_launcher$new( name = NULL, workers = NULL, seconds_interval = NULL, seconds_timeout = NULL, seconds_launch = NULL, seconds_idle = NULL, seconds_wall = NULL, seconds_exit = NULL, tasks_max = NULL, tasks_timers = NULL, reset_globals = NULL, reset_packages = NULL, reset_options = NULL, garbage_collection = NULL, crashes_error = NULL, launch_max = NULL, tls = NULL, processes = NULL, r_arguments = NULL, options_metrics = NULL )
name
See crew_launcher()
.
workers
See crew_launcher()
.
seconds_interval
See crew_launcher()
.
seconds_timeout
See crew_launcher()
.
seconds_launch
See crew_launcher()
.
seconds_idle
See crew_launcher()
.
seconds_wall
See crew_launcher()
.
seconds_exit
See crew_launcher()
.
tasks_max
See crew_launcher()
.
tasks_timers
See crew_launcher()
.
reset_globals
See crew_launcher()
.
reset_packages
See crew_launcher()
.
reset_options
See crew_launcher()
.
garbage_collection
See crew_launcher()
.
crashes_error
See crew_launcher()
.
launch_max
Deprecated.
tls
See crew_launcher()
.
processes
See crew_launcher()
.
r_arguments
See crew_launcher()
.
options_metrics
See crew_launcher()
.
An R6
object with the launcher.
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) { client <- crew_client() client$start() launcher <- crew_launcher_local() launcher$start(url = client$url, profile = client$profile) launcher$launch() task <- mirai::mirai("result", .compute = client$profile) mirai::call_mirai_(task) task$data client$terminate() }
validate()
Validate the launcher.
crew_class_launcher$validate()
NULL
(invisibly).
poll()
Poll the throttle.
crew_class_launcher$poll()
TRUE
to run whatever work comes next, FALSE
to skip
until the appropriate time.
settings()
List of arguments for mirai::daemon()
.
crew_class_launcher$settings()
List of arguments for mirai::daemon()
.
call()
Create a call to crew_worker()
to
help create custom launchers.
crew_class_launcher$call( worker, socket = NULL, launcher = NULL, instance = NULL )
worker
Character string, name of the worker.
socket
Deprecated on 2025-01-28 (crew
version 1.0.0).
launcher
Deprecated on 2025-01-28 (crew
version 1.0.0).
instance
Deprecated on 2025-01-28 (crew
version 1.0.0).
Character string with a call to crew_worker()
.
launcher <- crew_launcher_local() launcher$start(url = "tcp://127.0.0.1:57000", profile = "profile") launcher$call(worker = "worker_name") launcher$terminate()
start()
Start the launcher.
crew_class_launcher$start(url = NULL, profile = NULL, sockets = NULL)
url
Character string, websocket URL for worker connections.
profile
Character string, mirai
compute profile.
sockets
Deprecated on 2025-01-28 (crew
version 1.0.0).
NULL
(invisibly).
terminate()
Terminate the whole launcher, including all workers.
crew_class_launcher$terminate()
NULL
(invisibly).
resolve()
Resolve asynchronous worker submissions.
crew_class_launcher$resolve()
NULL
(invisibly). Throw an error if there were any
asynchronous worker submission errors.'
update()
Update worker metadata, resolve asynchronous worker submissions, and terminate lost workers.
crew_class_launcher$update(status)
status
A mirai
status list.
NULL
(invisibly).
launch()
Launch a worker.
crew_class_launcher$launch()
Handle of the launched worker.
scale()
Auto-scale workers out to meet the demand of tasks.
crew_class_launcher$scale(status, throttle = NULL)
status
A mirai
status list with worker and task information.
throttle
Deprecated, only used in the controller
as of 2025-01-16 (crew
version 0.10.2.9003).
Invisibly returns TRUE
if there was any relevant
auto-scaling activity (new worker launches or worker
connection/disconnection events) (FALSE
otherwise).
launch_worker()
Abstract worker launch method.
crew_class_launcher$launch_worker(call, name, launcher, worker)
call
Character of length 1 with a namespaced call to
crew_worker()
which will run in the worker and accept tasks.
name
Character of length 1 with an informative worker name.
launcher
Character of length 1, name of the launcher.
worker
Positive integer of length 1, index of the worker. This worker index remains the same even when the current instance of the worker exits and a new instance launches. It is always between 1 and the maximum number of concurrent workers.
Launcher plugins will overwrite this method.
A handle to mock the worker launch.
terminate_worker()
Abstract worker termination method.
crew_class_launcher$terminate_worker(handle)
handle
A handle object previously
returned by launch_worker()
which allows the termination
of the worker.
Launcher plugins will overwrite this method.
A handle to mock worker termination.
terminate_workers()
Terminate all workers.
crew_class_launcher$terminate_workers()
NULL
(invisibly).
crashes()
Deprecated on 2025-01-28 (crew
version 1.0.0).
crew_class_launcher$crashes(index = NULL)
index
Unused argument.
The integer 1, for compatibility.
set_name()
Deprecated on 2025-01-28 (crew
version 1.0.0).
crew_class_launcher$set_name(name)
name
Name to set for the launcher.
NULL
(invisibly).
Other launcher:
crew_launcher()
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
client$start()
launcher <- crew_launcher_local()
launcher$start(url = client$url, profile = client$profile)
launcher$launch()
task <- mirai::mirai("result", .compute = client$profile)
mirai::call_mirai_(task)
task$data
client$terminate()
}
## ------------------------------------------------
## Method `crew_class_launcher$new`
## ------------------------------------------------
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
client$start()
launcher <- crew_launcher_local()
launcher$start(url = client$url, profile = client$profile)
launcher$launch()
task <- mirai::mirai("result", .compute = client$profile)
mirai::call_mirai_(task)
task$data
client$terminate()
}
## ------------------------------------------------
## Method `crew_class_launcher$call`
## ------------------------------------------------
launcher <- crew_launcher_local()
launcher$start(url = "tcp://127.0.0.1:57000", profile = "profile")
launcher$call(worker = "worker_name")
launcher$terminate()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.