Skip to content

Commit

Permalink
Update for newer version of rrq. (#4)
Browse files Browse the repository at this point in the history
rrq does not create a configuration key anymore as of 0.7.20, which we'd
been using to enumerate all the queues. We now use `controller` instead,
which should preserve the previous behaviour.

This also switches the enumeration of workers to use the status key
instead of id, as the latter only includes lives workers.
  • Loading branch information
plietar authored Nov 11, 2024
1 parent 317271b commit 4de9c28
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ asISO8601 <- function(t) strftime(t, "%Y-%m-%dT%H:%M:%SZ", tz = "UTC")

get_controller_keys <- function(con, controller_id) {
keys <- rrq:::rrq_keys(controller_id)
if (!as.logical(con$EXISTS(keys$configuration))) {
if (!as.logical(con$EXISTS(keys$controller))) {
porcelain::porcelain_stop(
sprintf("rrq controller %s does not exist", controller_id),
status_code = 404L)
Expand All @@ -25,8 +25,8 @@ redis_scan <- function(con, pattern) {

target_controller_list <- function(con) {
function() {
keys <- redis_scan(redux::hiredis(), "rrq:*:configuration")
controllers <- sub("(.*):configuration$", "\\1", keys)
keys <- redis_scan(redux::hiredis(), "rrq:*:controller")
controllers <- sub("(.*):controller$", "\\1", keys)
list(controllers = data.frame(id = controllers))
}
}
Expand Down Expand Up @@ -80,7 +80,7 @@ target_worker_list <- function(con) {
function(controller_id) {
keys <- get_controller_keys(con, controller_id)

ids <- unlist(con$SMEMBERS(keys$worker_id))
ids <- unlist(con$HKEYS(keys$worker_status))
if (length(ids) == 0) {
return(list(workers=list()))
}
Expand Down

0 comments on commit 4de9c28

Please sign in to comment.