Skip to content

Commit

Permalink
Pause execution if request limit reached (#123)
Browse files Browse the repository at this point in the history
* Sleep if request limit reached

* Increment version number to 0.1.3.9000
  • Loading branch information
judith-bourque authored Jun 16, 2023
1 parent ad2a717 commit c3fb4de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: locateip
Title: Locate IP Addresses with 'ip-api'
Version: 0.1.3
Version: 0.1.3.9000
Authors@R:
person("Judith", "Bourque", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0009-0000-3653-1530"))
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# locateip (development version)

# locateip 0.1.3

* Added a `NEWS.md` file to track changes to the package.
Expand Down
5 changes: 5 additions & 0 deletions R/locate.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ get_location <-
resp <- create_req(ip = ip, fields = fields, lang = lang, header = header, ..., format = format) |>
httr2::req_perform()

# If there's no remaining requests, pause execution
if (as.numeric(httr2::resp_header(resp, "X-Rl")) == 0) {
Sys.sleep(as.numeric(httr2::resp_header(resp, "X-Ttl")))
}

return(resp)
}

Expand Down

0 comments on commit c3fb4de

Please sign in to comment.