Geneos-API
view release on metacpan or search on metacpan
lib/Geneos/API.pm view on Meta::CPAN
The constructor accepts a reference to the options hash as optional second parameter:
my $api = Geneos::API->new("http://localhost:7036/xmlrpc", {
api => {
# XML-RPC API options:
raise_error => 1,
},
ua => {
# UserAgent options:
keep_alive => 20,
timeout => 60,
},
});
=head4 B<api> - XML-RPC options
=over
=item * C<< raise_error >>
lib/Geneos/API.pm view on Meta::CPAN
my $api = Geneos::API->new("http://example.com:7036/xmlrpc", {api=>{raise_error=>1,},});
=head4 B<ua> - UserAgent options
=over
=item * C<< any options supported by L<LWP::UserAgent> >>
=back
If no LWP::UserAgent options are passed to the constructor, the keep alive will be enabled with the total capacity of 10. In other words, the two calls below are identical:
$api = Geneos::API->new("http://localhost:7036/xmlrpc")
# is identical to
$api = Geneos::API->new("http://localhost:7036/xmlrpc", {
ua => {
keep_alive => 10,
},
});
# but different to (keep alive disabled):
$api = Geneos::API->new("http://localhost:7036/xmlrpc", {
ua => {},
});
Note that if you pass the LWP::UserAgent options, the keep alive default won't be applied:
# keep alive is not enabled
$api = Geneos::API->new("http://localhost:7036/xmlrpc", {
ua => {
timeout => 300,
},
});
Examples:
# sets http timeout to 30 seconds and implicitly disables keep alive:
$api = Geneos::API->new("http://example.com:7036/xmlrpc", {
ua => {
timeout=>30,
},
});
# sets the agent name to "geneos-client/1.00"
$api = Geneos::API->new("http://example.com:7036/xmlrpc", {
ua => {
agent=>"geneos-client/1.00",
lib/Geneos/API.pm view on Meta::CPAN
# package Geneos::API::XMLRPC
#
# XML-RPC client
# The reason for yet another XML-RPC implementation is that
# because Geneos XML-RPC does not conform to the XML-RPC standard:
#
# * '-', '(' and ')' characters may be used in the method names
# * the values do not default to type 'string'
#
# Among other reasons, ensuring that HTTP1.1 is used to take advantage
# of the keep alive feature supported by Geneos XML-RPC server
#
########################################################################
package Geneos::API::XMLRPC;
use LWP::UserAgent;
use Time::HiRes qw(gettimeofday);
# -----------
# Constructor
lib/Geneos/API.pm view on Meta::CPAN
# if options are passed - it must be a hashref
if ($opts) {
croak "Options for Geneos::API->new must be passed as a HASHREF!" unless ref($opts) eq 'HASH';
}
else {
# init the options
$opts ||= {};
}
# enable keep alive by default
$opts->{ua} ||= {keep_alive=>DEFAULT_TOTAL_CAPACITY,};
# no api options are set by default
$opts->{api} ||= {};
$self->{_xmlrpc} = Geneos::API::XMLRPC->new($url, $opts);
$self->{_opts} = $opts;
# ----------------------
# init the error handler
( run in 0.627 second using v1.01-cache-2.11-cpan-39bf76dae61 )