add_service: Add a Service Route to the Microservice

Description Usage Arguments Details Value See Also Examples

Description

Add a Service Route to the Microservice

Usage

1
add_service(path = ".", name, overwrite = FALSE)

Arguments

path

(character) Where is the project root folder?

name

(character) what is the service route name? For example, if name = "repository" then the set of services would become available at http://127.0.0.1:8080/repository/.

overwrite

(logical) Should existing destination files be overwritten?

Details

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.

How It Works

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

When to Use

In scenarios where services are thematically linked to each other. Examples for themes that should be mounted separately:

Value

No return value, called for side effects.

See Also

Other microservice utilities: use_microservice()

Examples

1
2
3
4
5
6
7
path <- tempfile()
dir.create(path, showWarnings = FALSE, recursive = TRUE)
use_microservice(path)

add_service(path, name = "repository")

list.files(path, recursive = TRUE)

usethat documentation built on Sept. 20, 2021, 5:08 p.m.