Skip to content

Commit

Permalink
More general verification approach
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Oct 22, 2024
1 parent 2cce6f4 commit 825af70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 1 addition & 4 deletions R/location.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ orderly_location_add <- function(name, type, args, verify = TRUE, root = NULL) {

if (verify) {
cli_alert_info("Testing location")
driver <- location_driver_create(type, args)
if (!is.null(driver$authorise)) {
driver$authorise()
}
location_driver_create(type, args)$verify()
cli_alert_success("Location configured successfully")
}

Expand Down
12 changes: 12 additions & 0 deletions R/location_http.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ orderly_location_http <- R6::R6Class(
self$client <- outpack_http_client$new(url, authorise)
},

verify = function() {
## This should never end up triggering the assertion here as
## http_client_handle_error() in the client will convert
## unsuccessful requests into an error already, but this should
## serve as a reasonable backstop.
##
## The act of making the request will force validation, which is
## the most likely source of errors (along with getting the URL
## wrong).
stopifnot(identical(self$client$request("/")$status, "success"))
},

authorise = function() {
self$client$authorise()
},
Expand Down
4 changes: 4 additions & 0 deletions R/location_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ orderly_location_path <- R6::R6Class(
private$root <- root_open(path, require_orderly = FALSE)
},

verify = function() {
## No implementation needed as we verify the root in initialize()
},

list = function() {
private$root$index$location(local)[c("packet", "time", "hash")]
},
Expand Down

0 comments on commit 825af70

Please sign in to comment.