NAME

AnyEvent::HTTP::MultiGet - AnyEvent Loop Control Freindly LWP Like agent

SYNOPSIS

use AnyEvent::HTTP::MultiGet;
use AnyEvent::Loop;
use Test::More;
use Data::Dumper;

my $self=AnyEvent::HTTP::MultiGet->new();
my $count=0;
TEST_LOOP: {
  my $req=HTTP::Request->new(GET=>'http://google.com');
  my @todo=HTTP::Request->new(GET=>'http://yahoo.com');
  push @todo,HTTP::Request->new(GET=>'http://news.com');
  my $total=2 + scalar(@todo);

  my $req_b=HTTP::Request->new(GET=>'https://127.0.0.1:5888');
  my $code;
  $code=sub {
    my ($obj,$request,$result)=@_;
    diag sprintf 'HTTP Response code: %i',$result->code;
    ++$count;
    if(my $next=shift @todo) {
      $self->add_cb($req,$code);
      $self->run_next;
    }
    no warnings;
    last TEST_LOOP if $total==$count;
  };
  $self->add_cb($req,$code);
  $self->add_cb($req_b,$code);
  $self->run_next;
  AnyEvent::Loop::run;
}

DESCRIPTION

This class provides an AnyEvent::Loop::run frienddly implementation of HTTP::MultiGet.

OO Arguments and accessors

Arguemnts and object accessors:

logger:          DOES(Log::Log4perl::Logger)
request_opts:    See AnyEvent::HTTP params for details
timeout:         Global timeout for everything 
max_que_count:   How many requests to run at once 
max_retry:       How many times to retry if we get a connection/negotiation error 

For internal use only:

in_control_loop: true when in the control loop
stack:           Data::Queue object 
que_count:       Total Number of elements active in the que
retry:           Anonymous hash used to map ids to retry counts
cb_map:          Anonymous hash used to map ids to callbacks

OO Methods

  • my $id=$self->add_cb($request,$code)

    Adds a request with a callback handler.

AUTHOR

Michael Shipper <AKALINUX@CPAN.ORG>