Skip to content

Commit

Permalink
docs: read_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Feb 6, 2024
1 parent 3fb462a commit ee4d786
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 61 deletions.
6 changes: 3 additions & 3 deletions R/Rush.R
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,10 @@ Rush = R6::R6Class("Rush",
#' @description
#' Reads a single Redis hash and returns the values as a list named by the fields.
#'
#' @param keys (`character()`)\cr
#' Keys of the hashes.
#' @param key (`character(1)`)\cr
#' Key of the hash.
#' @param fields (`character()`)\cr
#' Fields to be read from the hashes.
#' Fields to be read from the hash.
#'
#' @return (list of `list()`)\cr
#' The outer list contains one element for each key.
Expand Down
59 changes: 38 additions & 21 deletions man/Rush.Rd

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

39 changes: 2 additions & 37 deletions man/RushWorker.Rd

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

1 change: 1 addition & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ reference:
contents:
- get_hostname
- rush-package
- with_rng_state
21 changes: 21 additions & 0 deletions tests/testthat/test-Rush.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ test_that("globals are available on the worker", {
expect_rush_reset(rush)
})

test_that("named globals are available on the worker", {
skip_on_cran()
skip_on_ci()

config = start_flush_redis()
rush = Rush$new(network_id = "test-rush", config = config)
fun = function(x1, x2, ...) list(y = z)
x <<- 33

rush$start_workers(fun = fun, n_workers = 2, globals = c(z = "x"), wait_for_workers = TRUE)

xss = list(list(x1 = 1, x2 = 2))
keys = rush$push_tasks(xss)
rush$wait_for_tasks(keys, detect_lost_workers = TRUE)

expect_equal(rush$n_finished_tasks, 1)
expect_equal(rush$fetch_finished_tasks()$y, 33)

expect_rush_reset(rush)
})

# start workers with script ----------------------------------------------------

test_that("worker can be started with script", {
Expand Down

0 comments on commit ee4d786

Please sign in to comment.