Skip to content

Commit

Permalink
feat: all_workers_lost field
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Apr 17, 2024
1 parent df1816d commit 3f8cac6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
34 changes: 34 additions & 0 deletions R/Rush.R
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,31 @@ Rush = R6::R6Class("Rush",
as.integer(r$SCARD(private$.get_key("running_worker_ids"))) %??% 0
},

#' @field n_terminated_workers (`integer(1)`)\cr
#' Number of terminated workers.
n_terminated_workers = function(rhs) {
assert_ro_binding(rhs)
r = self$connector
as.integer(r$SCARD(private$.get_key("terminated_worker_ids"))) %??% 0
},

#' @field n_killed_workers (`integer(1)`)\cr
#' Number of killed workers.
n_killed_workers = function(rhs) {
assert_ro_binding(rhs)
r = self$connector
as.integer(r$SCARD(private$.get_key("killed_worker_ids"))) %??% 0
},

#' @field n_lost_workers (`integer(1)`)\cr
#' Number of lost workers.
#' Run `$detect_lost_workers()` to update the number of lost workers.
n_lost_workers = function(rhs) {
assert_ro_binding(rhs)
r = self$connector
as.integer(r$SCARD(private$.get_key("lost_worker_ids"))) %??% 0
},

#' @field worker_ids (`character()`)\cr
#' Ids of workers.
worker_ids = function() {
Expand Down Expand Up @@ -1323,6 +1348,15 @@ Rush = R6::R6Class("Rush",
rbindlist(worker_ids, idcol = "state", use.names = TRUE, fill = TRUE)
},

#' @field all_workers_lost (`logical(1)`)\cr
#' Whether all workers are lost.
#' Runs `$detect_lost_workers()` to detect lost workers.
all_workers_lost = function(rhs) {
assert_ro_binding(rhs)
self$detect_lost_workers()
self$n_workers == self$n_lost_workers
},

#' @field priority_info ([data.table::data.table])\cr
#' Contains the number of tasks in the priority queues.
priority_info = function(rhs) {
Expand Down
14 changes: 14 additions & 0 deletions man/Rush.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f8cac6

Please sign in to comment.