Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Paging with REST::Client?

by bliako (Monsignor)
on Jan 11, 2020 at 15:06 UTC ( [id://11111328]=note: print w/replies, xml ) Need Help??


in reply to Paging with REST::Client?

and I'm hitting the max amount of data REST::Client will accept. 

What do you mean? Does the module REST::Client impose a limit or does the server impose a limit?

What I understand is that either the server has paging into their API, so that you can do something like $client->GET('http://example.com/dir/file.xml?page=10&num_pages=1'); in a loop to get all the pages. OR the server has no paging to offer and you get all the data at once. In which case REST::Client has the option to save it to a file if handling it in Perl, as a variable, will cause you problems. The file can then easily be paged in the usual ways.

LWP::UserAgent allows you to provide your own callback functions to be called before and after each phase of handling the requests. But I can't see how this can be useful in your case. What I thought would be possible is to ask user-agent to give you a data-socket and do what you want with it but don't know how or if it makes sense.

Edit: How to make REST::Client save to a file from its documentation:

# request responses can be written directly to a file $client->setContentFile( "FileName" ); # or call back method $client->setContentFile( \&callback_method );

Replies are listed 'Best First'.
Re^2: Paging with REST::Client?
by Argel (Prior) on Jan 13, 2020 at 19:10 UTC
    Thanks for taking a closer look. I skimmed over the callback stuff in LWP::Useragent and it didn't leave me optimistic. Might be more useful if I write this using just LWP::UserAgent, but I don't think I will have time for that.

    I'll look into writing to a file. My guess is that I'm going to hit the max data cap regardless, unless REST::Client is setting a cap to protect the user.

    Hmm, maybe I'm thinking about this the wrong way. If I hit max data then I know I have pending changes, so a restart is needed. So I know I hit max data I can proceed with my processing (checking if a restart is already in progress). I'll check what error information REST::Client gets me and see what I can do with that.

    Elda Taluta; Sarks Sark; Ark Arks
    My deviantART gallery

      I'll look into writing to a file. My guess is that I'm going to hit the max data cap regardless, unless REST::Client is setting a cap to protect the user.

      Hi

      Can you explain what "max data cap" means?

      Because its not in the URL vocabulary, HTTP vocabulary, REST vocabulary, and predictably, not even in perl LWP module family or REST::Client vocabulary

      Whats is it that you're describing exactly?

      I know its not a sticker on the window of your car , right?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111328]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-24 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found