NAME
Net::API::CPAN::Scroll - Meta CPAN API Search Scroller
SYNOPSIS
use Net::API::CPAN::Scroll;
my $this = Net::API::CPAN::Scroll->new(
time => '1m',
size => 1000,
) || die( Net::API::CPAN::Scroll->error, "\n" );
VERSION
v0.1.0
DESCRIPTION
This class is used to access a list of data like Net::API::CPAN::List from which it inherits, but uses Elastic Search scroller. See the perl module
Note that with the scroll search, you can only scroll forward and not backward, which means you can only use next, but not prev
CONSTRUCTOR
new
Provided with an hash or an hash reference of parameters and this will instantiate a new list object.
The valid parmeters that can be used are as below and can also be accessed with their corresponding method:
api
An Net::API::CPAN object.
items
An array reference of data.
METHODS
close
my $resp = $scroll->close; # returns an HTTP::Promise::Response object
If a scroll ID is set, this will issue a DELETE
HTTP
query to clear the scroll, and return the resulting HTTP::Promise::Response, or, upon error, this will set an error object and return undef
in scalar context, or an empty list in list context.
The HTTP
payload would look like something this:
{
"scroll_id" : ["c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1"]
}
Alternatively, if you pass the option all
with a true value, this will issue an HTTP
query to clear all scroll.
See also Elastic Search documentation
id
Sets or gets the scroll ID as returned by the MetaCPAN API in the _scroll_id
property.
It returns a regular string representing the scroll ID, or undef
if none were set.
postprocess
This method is called by "load" with the hash reference of data received from the MetaCPAN API, for possible post processing.
It returns the current object for chaining, or upon error, sets an error and returns undef
in scalar context or an empty list in list context.
size
Sets or gets the size of the data to be returned by the Elastic Search.
Returns a number object, or undef
if an error occurred.
time
Same as "ttl"
ttl
$scroll->ttl( '1m' );
my $time = $scroll->ttl;
Sets or gets the value for how long the data should be kept alive by Elastic Search.
Possible unit to use next to the integer are:
y
YearM
Monthw
Weekd
Dayh
Hourm
Minutes
Secondms
Milli-second
See Elastic Search documentation on valid units
Returns a scalar object upon success, or sets an error Net::API::CPAN::Exception and returns undef
in scalar context, or an empty list in list context.
uri
Returns the URI to use for the scroll search, which will contain some query string even if the query is using HTTP
POST
method. For example:
POST /v1/author/_search?scroll=1m
{
"size": 100,
"query": {
"match": {
"message": "foo"
}
}
}
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
COPYRIGHT & LICENSE
Copyright(c) 2023 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.