Add a Service Route to the Microservice
add_service(path = ".", name, overwrite = FALSE)
path | ( |
---|---|
name | ( |
overwrite | ( |
No return value, called for side effects.
Lay the infrastructure for an additional set of services. That includes adding a unit test, adding an endpoint, and extending the entrypointy.
Note: add_service
adds a service to pre-existing plumber
microservice which you could deploy by calling use_microservice
.
Given a path
(.) to a folder and a name
(repository)
When add_service
is called
Then the function creates the following files:
tests/testthat/test-endpoint-plumber-repository.R inst/endpoints/plumber-repository.R
And updates the following files:
inst/entrypoints/plumber-foreground.R
In scenarios where services are thematically linked to each other. Examples for themes that should be mounted separately:
‘forecasting’ and ‘anomaly detection’
‘user’ and ‘business’
Other microservice utilities:
use_microservice()
path <- tempfile() dir.create(path, showWarnings = FALSE, recursive = TRUE) use_microservice(path) add_service(path, name = "repository") list.files(path, recursive = TRUE)#> [1] "DESCRIPTION" #> [2] "inst/configurations/plumber.yml" #> [3] "inst/endpoints/plumber-repository.R" #> [4] "inst/endpoints/plumber-utility.R" #> [5] "inst/entrypoints/plumber-background.R" #> [6] "inst/entrypoints/plumber-foreground.R" #> [7] "tests/testthat/helpers-xyz.R" #> [8] "tests/testthat/test-endpoint-plumber-repository.R" #> [9] "tests/testthat/test-endpoint-plumber-utility.R"