Hi folks:

Not sure if many people are doing this, but let me try to indicate what I am doing. I replaced a blocking Mojo::UserAgent call with an asynchronous version, and the associated call back/closure.

  First off, this all works.  The code in question is as follows

    my $tx         = $ua->build_tx(GET => $url);
    $output        = "";
    $tx->res->max_message_size(0);
    $tx->res->content->unsubscribe('read')
            ->on(read => sub {
                  my ($content, $bytes) = @_;
                $tf        = [gettimeofday];
                $dt        = tv_interval ($t0,$tf);
                $t0        = $tf;
printf STDERR "D[%i] Scalable::TSDB::_send_chunked_get_query -> reading %-.6fs \n",$$,$dt if ($self->debug()) ;
                  $output .= $bytes;
    });

    # Process transaction
    $ret = $ua->start($tx);

Largely a cut and paste from the UserAgent portion of the cookbook, and other docs.

This works.

But it raises other issues. In the code it replaced, I could get a return code from the remote server for the request, that I used in diagnostics. Now that is somewhat less defined (return code for each chunk or for all chunks), and where/how do I access it?

I would imagine that if we have a return code per chunk, that I could push these onto an array, and then search for anything not a particular set of values (a naive approach, but we need to start somewhere). But then the question of how to handle M bad chunks out of N, or indicate that we have missing chunks?

I don't control the server side of this, and am simply developing a client for the service. So for the moment I can't change the server side.

This said, how do people a) detect, b) handle missing chunks or errors in chunks? The error detection part is non-trivial, as I don't think many servers provide CRC/Content-MD5 headers per chunk. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.15

Does anyone have advice/experience/guidance on any of this? For this application, its not so important if we miss data (read only access to data), but I'd like to know if this is a solved problem, and if so how people solved it. Googling didn't help much here.

Thanks in advance!


--
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to