use OpenSRF::MultiSession;
use OpenILS::Utils::Fieldmapper;
use OpenILS::Utils::CStoreEditor q/:funcs/;
-use Net::HTTP::NB;
use OpenILS::Application::AppUtils;
+use Net::HTTP::NB;
+
my $U = 'OpenILS::Application::AppUtils';
params => [
{desc => 'Authentication token', type => 'string'},
{desc => 'Session ID (url_verify.session.id)', type => 'number'},
- {desc => 'URL ID list (optional)', type => 'array'}
+ {desc => 'URL ID list (optional). An empty list will result in no URLs being processed', type => 'array'},
+ {
+ desc => q/
+ Options (optional).
+ report_all => bypass response throttling and receive all URL sub-process responses.
+ Not recommened for remote clients, because it can be a lot of data.
+ /,
+ type => 'hash'
+ }
],
- return => {desc => 'TODO'}
+ return => {desc => q/
+ Stream of objects containing the number of URLs to be processed (url_count),
+ the number processed thus far including redirects (total_processed),
+ and the current url_verification object (current_verification).
+
+ Note that total_processed may ultimately exceed url_count, since it
+ includes non-anticipate-able redirects.
+
+ The final response contains url_count, total_processed, and the
+ verification_attempt object (attempt).
+ /
+ }
}
);
join => { cbreb => { # bucket
join => { uvs => { # session
filter => {id => $session_id}
- }}
- }}
- }
- }
+ }} # noisses
+ }} # tekcub
+ } # meti tekcub
+ } # lru
}
});
success_handler => sub {
my ($self, $req) = @_;
- # API call streams fleshed url_verification objects. We wrap
+ # API call streams fleshed url_verification objects. We wrap
# those up with some extra info and pass them on to the caller.
for my $resp (@{$req->{response}}) {
my $content = $resp->content;
-
+
if ($content) {
$num_processed++;
});
}
- # start off responding quickly, then throttle
+ # start off responding quickly, then throttle
# back to only relaying every 256 messages.
$resp_window *= 2 unless $resp_window == 256;
}
}
# insert the per-thread delay, which keeps this thread
- # active, which prevents a new thread from firing up to
+ # active, which prevents a new thread from firing up to
# replace it. (thread = multisession session)
sleep $delay;
},
# Queue up the requests and let them fly
$multises->request(
- 'open-ils.url_verify.verify_url',
- $auth, $attempt->id, $_) for @$url_ids;
+ 'open-ils.url_verify.verify_url',
+ $auth, $attempt->id, $_) for @$url_ids;
# Wait for all requests to be completed
$multises->session_wait(1);
my $url = $e->retrieve_url_verify_url($url_id) or return $e->event;
my $attempt = $e->retrieve_url_verify_verification_attempt([
- $attempt_id, {
- flesh => 1,
+ $attempt_id, {
+ flesh => 1,
flesh_fields => {uvva => ['session']}
}
]) or return $e->event;
my $session = $attempt->session;
-
+
return $e->event unless $e->allowed('VERIFY_URL');
my $depth = 0;
}
$seen_urls{$cur_url->url} = $cur_url;
-
+
my $url_resp = validate_one_url($e, $attempt, $cur_url, $timeout);
# something tragic happened
$vcation->res_text('Max Redirects');
}
- $e->xact_begin;
+ $e->xact_begin;
$e->create_url_verify_url_verification($vcation) or return $e->die_event;
$e->xact_commit;
}
my $url_text = $url->url;
my $redir_url;
- # first, create the verification object so we can a) indicate that
+ # first, create the verification object so we can a) indicate that
# we're working on this URL and b) get the DB to set the req_time.
my $vcation = Fieldmapper::url_verify::url_verification->new;
# begin phase-I DB communication
- $e->xact_begin;
+ $e->xact_begin;
$e->create_url_verify_url_verification($vcation) or return $e->die_event;
$e->xact_commit;
my $sel = IO::Select->new($req);
- if ($sel->can_read($timeout)) {
+ if ($sel->can_read($timeout)) {
# request headers are ready for reading
} else {
$logger->info("url: server returned 3XX but no 'Location' header for url $url_text");
}
- }
+ }
}
} else {
$logger->info("url: request timed out for $url_text");
}
- } else {
+ } else {
# Error building connection. Invalid hostname, etc.