register.Rd
Register a directory on a shared filesystem for inclusion into the search index. This assumes that the directory is world-readable and the caller has write access to it.
register(dir, names, url, retry = 3, wait = 1, block = TRUE)
String containing the path to the directory to be registered. This may be a relative or absolute path.
Character vector containing the base names of the metadata files.
String containing the URL to the SewerRat REST API.
Deprecated arguments, ignored.
Logical scalar indicating whether to block on successful registration.
On success, the directory is registered and NULL is invisibly returned. A warning is raised if any particular metadata file cannot be indexed.
If block=FALSE
, the function returns before confirmation of successful registration from the SewerRat API.
This can be useful for asynchronous processing of directories with many files.
# Start up an example SewerRat service:
info <- startSewerRat()
# Mocking up a directory:
tmp <- tempfile()
dir.create(tmp)
write(file=file.path(tmp, "metadata.json"), '{ "name": "Aaron" }')
# Once we register it, we can query its contents.
register(tmp, "metadata.json", url=info$url)
query("Aaron", url=info$url)
#> [[1]]
#> [[1]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce1670f50f/metadata.json"
#>
#> [[1]]$user
#> [1] "root"
#>
#> [[1]]$time
#> [1] 1749491763
#>
#> [[1]]$metadata
#> [[1]]$metadata$name
#> [1] "Aaron"
#>
#>
#>
#> [[2]]
#> [[2]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce7c3c8466/metadata.json"
#>
#> [[2]]$user
#> [1] "root"
#>
#> [[2]]$time
#> [1] 1749491763
#>
#> [[2]]$metadata
#> [[2]]$metadata$first
#> [1] "Aaron"
#>
#> [[2]]$metadata$last
#> [1] "Lun"
#>
#>
#>
#> [[3]]
#> [[3]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce79fe193b/metadata.json"
#>
#> [[3]]$user
#> [1] "root"
#>
#> [[3]]$time
#> [1] 1749491762
#>
#> [[3]]$metadata
#> [[3]]$metadata$first
#> [1] "Aaron"
#>
#> [[3]]$metadata$last
#> [1] "Lun"
#>
#>
#>
#> [[4]]
#> [[4]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce7715ec9e/metadata.json"
#>
#> [[4]]$user
#> [1] "root"
#>
#> [[4]]$time
#> [1] 1749491762
#>
#> [[4]]$metadata
#> [[4]]$metadata$first
#> [1] "Aaron"
#>
#> [[4]]$metadata$last
#> [1] "Lun"
#>
#>
#>
#> [[5]]
#> [[5]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce3dba865d/metadata.json"
#>
#> [[5]]$user
#> [1] "root"
#>
#> [[5]]$time
#> [1] 1749491762
#>
#> [[5]]$metadata
#> [[5]]$metadata$first
#> [1] "Aaron"
#>
#> [[5]]$metadata$last
#> [1] "Lun"
#>
#>
#>
#> [[6]]
#> [[6]]$path
#> [1] "/tmp/RtmpOvzCpk/file1ce2d05a2ad/metadata.json"
#>
#> [[6]]$user
#> [1] "root"
#>
#> [[6]]$time
#> [1] 1749491762
#>
#> [[6]]$metadata
#> [[6]]$metadata$first
#> [1] "Aaron"
#>
#> [[6]]$metadata$last
#> [1] "Lun"
#>
#>
#>