BiodbRequestScheduler-class {biodb} | R Documentation |
This class handles GET and POST requests, as well as file downloading. Each
remote database connection instance (instance of concrete class inheriting
from BiodbRemotedbConn
, creates an instance of
BiodbRequestScheduler
for handling database connection. A timer is
used to schedule connections, and avoid sending too much requests to the
database. This class is not meant to be used directly by the library user.
See section Fields for a list of the constructor's parameters.
downloadFile(url, dest.file)
:
Downloads the content of a URL and save it into the specified destination file.
url: The URL to access, as a BiodbUrl object.
dest.file: A path to a destination file.
Returned value: None.
getUrl(
url,
params = list(),
method = c("get", "post"),
header = character(),
body = character(),
encoding = integer()
)
Send a URL request, either with GET or POST method, and return result.
getUrlString(url, params = list())
Build a URL string, using a base URL and parameters to be passed.
sendRequest(request, cache.read = TRUE)
:
Sends a request, and returns content result.
request: A BiodbRequest instance.
cache.read: If set to TRUE, the cache system will be used. In case the same request has already been already run and its results saved into the cache, then the request is not run again, the targeted server not contacted, and the results are directly loaded from the cache system.
Returned value: The results returned by the contacted server, as a single string value.
sendSoapRequest(
url,
soap.request,
soap.action = NA_character_,
encoding = integer()
)
:
Sends a SOAP request to a URL. Returns the string result.
url: The URL to access, as a character string.
soap.request: The XML SOAP request to send, as a character string.
soap.action: The SOAP action to contact, as a character string.
encoding: The encoding to use.
Returned value: The results returned by the contacted server, as a single string value.
BiodbRemotedbConn
,
BiodbRequestSchedulerRule
, BiodbConnObserver
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get the scheduler sched <- mybiodb$getRequestScheduler() # Create a request object u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity' url <- BiodbUrl$new(url=u) url$setParam('chebiId', 15440) request <- BiodbRequest$new(method='get', url=url) # Send request sched$sendRequest(request) # Terminate instance. mybiodb$terminate() mybiodb <- NULL