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

feat: add possibility to change the timeout for the curl's connect phase #125

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgsearch (development version)

* pkgsearch now uses the `timeout` option to set the limit for the total
time of each HTTP request (#125, @gladkia).

# pkgsearch 3.1.3

* No user visible changes.
Expand Down
6 changes: 5 additions & 1 deletion R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ do_query <- function(query, server, from, size) {
check_count(from)
check_count(size)

# timeout for the curl's connect phase (in seconds)
timeout <- getOption("timeout", 60)

url <- server %+% "/package/_search?from=" %+%
as.character(from - 1) %+% "&size=" %+% as.character(size)
result <- http_post(
url, body = query,
headers = c("Content-Type" = "application/json"))
headers = c("Content-Type" = "application/json"),
options = list(timeout = timeout))
chain_error(
http_stop_for_status(result),
new_query_error(result, "search server failure")
Expand Down
9 changes: 9 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ ps("gabor", size = 5)
ps("Gábor", size = 5)
```

## Configuration

### Options

* `timeout`: pkgsearch follows the `timeout` options for HTTP requests
(i.e. for `pkg_search()` and `advanced_search()`. `timeout` is the limit
for the total time of the HTTP request, and it is in seconds. See
`?options` for details.

## More info

See the [complete documentation](https://r-hub.github.io/pkgsearch/).
Expand Down
Loading
Loading