Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A client to speak to an App::Cerberus server
Perl
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/App/Cerberus
.gitignore
Changes
README.pod
dist.ini

README.pod

SYNOPSIS

    use App::Cerberus::Client;

    my $client = App::Cerberus::Client->new(
        servers => 'http://localhost:5000',
    );

    my $client = App::Cerberus::Client->new(
        servers => [
            'http://host1:5000',
            'http://host2:5000',
        ],
        timeout => 0.2
    );

    my $info = $client->request(
        ip => '80.1.2.3,
        ua => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
    );

DESCRIPTION

App::Cerberus::Client is a simple HTTP client for talking to an App::Cerberus server. If more than one server is specified, they will be rotated in round robin fashion, and if any server fails, the next one will be tried until one responds succesfully, or all servers have failed.

METHODS

new()

    $client = App::Cerberus::Client->new(
        servers => 'http://host1:5000',
     OR servers => [ 'http://host1:5000', 'http://host2:5000' ],

        timeout => 0.1,
    );

The servers params accepts a single server or an array ref of servers. The timeout param is in seconds (defaults to 0.1 seconds). Keep this low as you don't want an overloaded App::Cerberus server to become a bottleneck.

request()

    $info = $client->request(%params);

Sends a request to one of the configured servers, failing over to the next server if there is any error. If all servers fail, it returns an empty hash-ref.

SEE ALSO

App::Cerberus
Dancer::Plugin::Cerberus
Something went wrong with that request. Please try again.