Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A client to speak to an App::Cerberus server

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Changes
Octocat-spinner-32 README.pod
Octocat-spinner-32 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.