Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_running() method #910

Open
schloerke opened this issue Jun 29, 2023 · 2 comments
Open

Add is_running() method #910

schloerke opened this issue Jun 29, 2023 · 2 comments
Labels
difficulty: intermediate Enterprising community members could help effort: medium < 3 days of work help wanted Solution is well-specified enough that any community member could fix
Milestone

Comments

@schloerke
Copy link
Collaborator

From @nbenn in https://community.rstudio.com/t/determine-whether-code-is-being-run-as-part-of-a-plumber-api/169128

I am looking for a reliable way of determining if code is being run "under" plumber. Something like what I believe shiny::isRunning() provides.

Thanks!


I'd like for it to take pr as a value and have it default to something like get_current_router() (or something) that possibly returns the currently running server and checks for a flag.

Could also have a method to return currently running plumber routers (if non-blocking) is implemented. And then the length of the routers could be checked for > 0.

@meztez meztez added this to the v1.3.0 milestone Nov 24, 2023
@meztez meztez added difficulty: intermediate Enterprising community members could help effort: medium < 3 days of work help wanted Solution is well-specified enough that any community member could fix labels Nov 24, 2023
@thomasp85
Copy link
Collaborator

Just to understand your thinking, you want a $is_running() method in pr, along with set_current_router()/get_current_router() to register a router globally as running. Then at last you want

is_running <- function(pr = get_current_router()) {
  pr$is_running()
}

@schloerke
Copy link
Collaborator Author

I believe a pr$isRunning() would be good to have. Maybe it can wrap around this logic?: https://github.com/rstudio/httpuv/blob/ff00e6b7c08d0bcf99f9d155bb16bed3a110a6cd/R/server.R#L60

Until there is non-blocking plumber execution, I believe we should wait to implement {set,get}_current_router()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: intermediate Enterprising community members could help effort: medium < 3 days of work help wanted Solution is well-specified enough that any community member could fix
Projects
None yet
Development

No branches or pull requests

3 participants