Net::Bullfinch - Perl wrapper for talking with Bullfinch
version 0.07
use Net::Bullfinch; my $client = Net::Bullfinch->new(host => '172.16.49.130'); my $req = { statement => 'some-query' }; my $items = $client->send( request_queue => 'test-net-kestrel', request => $req, response_queue_suffix => 'foobar' ); foreach my $item (@{ $items }) { # whatever }
Net::Bullfinch is a thin wrapper around Memcached::Client for communicating with a Bullfinch.
This module handles JSON encoding of the request, the addition of a response queue, waiting for a response, confirmation of the message, decoding of the response and deletion of the response queue.
Bullfinch supports adding a tracing a request so that performance metrics and responses can be tracked.
my $items = $client->send( request_queue => 'test-net-kestrel', request => $req, response_queue_suffix => 'foobar' trace => 1 );
A UUID will be added to the request. This UUID will be included in the performance code in bullfinch workers and included in the response you receive.
The IP address of the host that we'll be connecting to.
The port of the IP address of the host we'll be connecting to.
The prefix used for the name of the response queue.
Set the timeout (in milliseconds) that will be used when awaiting a response back from Bullfinch.
Send the request to the specified queue and await a response. The data should be a hashref and the queuename (optional) will be appended to response_prefix. This allows you to create a unique response queue per request.
response_prefix
# Response queue will be "response-net-kestrel-foobar" my $items = $client->send(\%data, "foobar");
Any messages sent in response (save the EOF message) are returned as an arrayref to the caller.
The optional process_by must be an ISO 8601 date.
process_by
The optional expiration is the number of seconds this request should live in the queue before expiring.
expiration
Cory G Watson <gphat@cpan.org>
This software is copyright (c) 2012 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Bullfinch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Bullfinch
CPAN shell
perl -MCPAN -e shell install Net::Bullfinch
For more information on module installation, please visit the detailed CPAN module installation guide.