R6
abstract class to build other subclasses
which launch and manage workers.
See also
Other launcher:
crew_launcher()
Active bindings
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.
Methods
Method new()
Launcher constructor.
Usage
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
)
Arguments
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()
.
Examples
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 settings()
List of arguments for mirai::daemon()
.
Returns
List of arguments for mirai::daemon()
.
Method call()
Create a call to crew_worker()
to
help create custom launchers.
Arguments
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).
Returns
Character string with a call to crew_worker()
.
Examples
launcher <- crew_launcher_local()
launcher$start(url = "tcp://127.0.0.1:57000", profile = "profile")
launcher$call(worker = "worker_name")
launcher$terminate()
Method start()
Start the launcher.
Method update()
Update worker metadata, resolve asynchronous worker submissions, and terminate lost workers.
Method scale()
Auto-scale workers out to meet the demand of tasks.
Method launch_worker()
Abstract worker launch method.
Arguments
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.
Method terminate_worker()
Abstract worker termination method.
Examples
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")
#> [1] "crew::crew_worker(settings = list(url = \"tcp://127.0.0.1:57000\", dispatcher = TRUE, asyncdial = FALSE, autoexit = 15L, cleanup = 1L, output = TRUE, maxtasks = Inf, idletime = Inf, walltime = Inf, timerstart = 0L, id = 1L, tls = NULL, rs = NULL), launcher = \"b8cb73c4\", worker = \"worker_name\", options_metrics = crew::crew_options_metrics(path = NULL, seconds_interval = 5))"
launcher$terminate()