-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Export randomPort() #2599
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
base: main
Are you sure you want to change the base?
Export randomPort() #2599
Conversation
6df1725
to
2c753fa
Compare
R/server.R
Outdated
#' randomPort() | ||
#' randomPort() | ||
#' randomPort(cache = FALSE) | ||
randomPort <- function(min = 3000L, max = 8000L, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to create and export this function? My sense was that httpuv::randomPort
was sufficient to address #2562. I guess that httpuv::randomPort
doesn't do the caching part, though. We should find out if the caching is desired for that issue.
Also, if we do keep this function, I don't it should have the same name as the function from httpuv. If both packages are attached, there will be a name conflict and the order of package loading will affect how code behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems necessary if we want to make it easy for users to know and replicate exactly what Shiny does by default. By exporting we can have the default value of the port
argument in runApp()
show users exactly what it does, rather than it magically filling in the default (it's much less likely that people will read the docs, find httpuv::randomPort()
, and know how to use it in a way that they're used to).
If that's a strong enough argument to export, maybe findPort()
would be a better name.
} | ||
else { | ||
# Try up to 20 random ports | ||
while (TRUE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had in mind a much more targeted change -- basically, replacing this (inside the else
) with httpuv::randomPort()
.
Closes #2562