NAME
Xango::Broker::Base - Base Class for Xango Broker
SYNOPSIS
package MyBroker;
use strict;
use base qw(Xango::Broker::Base);
DESCRIPTION
Xango::Broker::Base implements the common broker methods.
You should be using Xango::Broker::Pull or Xango::Broker::Push in your applications. See respective documentations.
OBJECT METHODS
spawn(%args)
Create a new Xango::Broker::Base object, and also spawn a new POE::Session using that new object. To start a Xango::Broker session, you should be using spawn(), and not new().
Accepts the same arguments as new().
new(%args)
Create a new Xango::Broker::Base object. Arguments passed to it are stored via initialize()
- Alias (scalar)
-
The POE session alias for the broker.
- ConfigFile (scalar)
-
Path to the config file used by Xango::Config. Values in this file will be used as the default value for other variables.
- EnableDnsCache
-
Flag to tell Xango if DNS caching should be used. By default it's on. Turn this off for short-running Xango process that want to avoid repeated DNS failures caused by a cached DNS query failure.
- DnsCacheClass (scalar)
-
Perl class to use for DNS cache.
- DnsCacheArgs (hashref | arrayref)
-
Arguments to the DNS cache constructor
- DnsCacheArgsDeref (boolean)
-
Try to de-reference the DNS cache constructor argument specified by DnsCacheArgs when creating the cache. This is required if your DNS cache class uses simple list values instead of hash/array refs (e.g. Cache::Cache and Cache::FastMmap)
- DnsCompClass (scalar)
-
Specify the POE component class to asynchronously resolve DNS requests. By default POE::Component::Client::DNS is used.
- HandlerAlias (scalar)
-
The POE session alias for the handler.
- HttpCompClass (scalar)
-
Specify the POE component class to handle the actual HTTP fetching. By default POE::Component::Client::HTTP is used.
- HttpCompArgs (hashref | arrayref)
-
Arguments to the HTTP fetching component constructor.
- MaxHttpComp (integer)
-
The number of concurrent http agents (i.e. the number of POE::Component::Client::HTTP sessions) that are allowed. The default is 10, but for anything other than a toy application, something in the order of 50 ~ 100 is the recommended value.
Unless this number is less than 10, the broker starts with 10 sessions, and successively grows the pool of agents when there are not enough agents to handle the currently available jobs, until the maximum is reached.
If the max is less than 10, the starting number if equal to the max.
initialize
Initializes the broker object.
attr(key => $value)
General purpose getter/stter for attributes.
dns_comp_class
The class name for DNS resolver component.
dns_comp_alias
The alias for DNS resolver component.
states
Returns the states list as passed to the POE::Session constructor.
STATES
States are all called either by yield() or post(). The arguments described below are to be used in that context, i.e. yield('state', $arg1, $arg2...)
check_job_type
create_dns_cache
Creates and sets the DNS cache. You probably don't need to worry about this.
create_http_comp_data
create_http_request
Creates a new HTTP::Request object to be fetched.
dispatch_http_fetch($job)
Start an HTTP fetch for $job. $job must have a HTTP fetcher associated to it.
dispatch_to_lightest_load($job)
Choose the HTTP fetcher session with the least load, and call dispath_http_fetch after associating it to a job
fake_error_response
Create a fake HTTP error response, which is passed to handle_http_response. This is used to notify internal errors to the handler.
install_sighandlers
Installs the global signal handlers.
spawn_dns_comp
Spawns the component to resolve DNS lookups.
spawn_http_comp($howmany)
signal_http_comp
Send a signal to the specified HTTP component.
shutdown_broker
Sets the shutdown flag on the broker. The broker will attempt to shutdown gracefully.
handle_dns_response
handle_http_response
handle_signal
Handle a given signal. The signal name is in ARG0.
register_dns_request
register_http_request
unregister_http_request
finalize_job
SEE ALSO
Xango::Broker::Pull Xango::Broker::Push
AUTHOR
Copyright (c) 2005-2006 Daisuke Maki <dmaki@cpan.org>. All rights reserved. Development funded by Brazil, Ltd. <http://b.razil.jp>