-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Description
I am writing an API and shipping it in an R package, as described briefly here:
https://www.rplumber.io/reference/plumb_api.html
It would be helpful to have a bit more information on how this is done.
In particular, for my case, I am interested in how I would register an exit handler, as described here:
https://www.rplumber.io/articles/execution-model.html#exit-handlers
Since I would call the package's API like:
plumber::plumb_api("pkg", "api") |> plumber::pr_run()
Do I register the exit handler in the API file inside the package ?
Or do I do it when I 'plumb' the package's API, like so:
plumber::plumb_api("pkg", "api") |>
plumber::pr_hook("exit", function(){ print("Bye bye!")})
plumber::pr_run()
What if the exit handler depends on an object defined in the package API ?
e.g.
plumber::plumb_api("pkg", "api") |>
plumber::pr_hook("exit", function(){ dbDisconnect(connection) }) ## <- 'connection' does not exist here
plumber::pr_run()
Metadata
Metadata
Assignees
Labels
No labels