view release on metacpan or search on metacpan
lib/Amazon/S3/Thin.pm view on Meta::CPAN
sub _default_ua {
my $self = shift;
my $ua = LWP::UserAgent->new(
keep_alive => 10,
requests_redirectable => [qw(GET HEAD DELETE PUT)],
);
$ua->timeout(30);
$ua->env_proxy;
return $ua;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Amazon/SQS/Simple/Base.pm view on Meta::CPAN
Version => $DEFAULT_SQS_VERSION,
@args
};
if (!defined($self->{UserAgent})) {
$self->{UserAgent} = LWP::UserAgent->new(keep_alive => 4);
}
if (defined($self->{Timeout})) {
$self->{UserAgent}->timeout($self->{Timeout});
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Amazon/SimpleDB.pm view on Meta::CPAN
my $args = shift || {};
my $self = bless $args, $class;
croak "No aws_access_key_id" unless $self->{aws_access_key_id};
croak "No aws_secret_access_key" unless $self->{aws_secret_access_key};
unless ($self->{agent}) {
my $agent = LWP::UserAgent->new(keep_alive => KEEP_ALIVE_CACHESIZE);
$agent->timeout(10);
$agent->env_proxy;
$self->{agent} = $agent;
}
return $self;
view all matches for this distribution
view release on metacpan or search on metacpan
Amethyst/Brain/Infobot/Module/Zippy.pm view on Meta::CPAN
Is this the line for the latest whimsical YUGOSLAVIAN drama which also makes you want to CRY and reconsider the VIETNAM WAR?
Isn't this my STOP?!
It don't mean a THING if you ain't got that SWING!!
It was a JOKE!! Get it?? I was receiving messages from DAVID LETTERMAN!!
YOW!!
It's a lot of fun being alive ... I wonder if my bed is made?!?
It's NO USE ... I've gone to "CLUB MED"!!
It's OBVIOUS ... The FURS never reached ISTANBUL ... You were an EXTRA in the REMAKE of "TOPKAPI" ... Go home to your WIFE ... She's making FRENCH TOAST!
It's OKAY -- I'm an INTELLECTUAL, too.
It's the RINSE CYCLE!! They've ALL IGNORED the RINSE CYCLE!!
JAPAN is a WONDERFUL planet -- I wonder if we'll ever reach their level of COMPARATIVE SHOPPING ...
view all matches for this distribution
view release on metacpan or search on metacpan
t/4023-object-demolish.t view on Meta::CPAN
'name:Str',
);
{
my $obj = WithDemolish->new(name => "test");
is(scalar @destroyed, 0, 'DEMOLISH not called while object alive');
}
is(scalar @destroyed, 1, 'DEMOLISH called when object destroyed');
like($destroyed[0], qr/WithDemolish::DEMOLISH called/, 'Correct DEMOLISH message');
# Test 2: Class without DEMOLISH has no overhead
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Any/Daemon/HTTP/Proxy.pm view on Meta::CPAN
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{ADHDP_ua} = $args->{user_agent}
|| LWP::UserAgent->new(keep_alive => 30);
$self->{ADHDP_via} = $args->{via};
if(my $fm = $args->{forward_map})
{ $self->{ADHDP_map} = $fm eq 'RELAY' ? sub {$_[3]} : $fm;
}
view all matches for this distribution
view release on metacpan or search on metacpan
Changes:
- move to Log::Report 1.0, only light form required.
Fixes:
- catch daemon errors with try not eval, to keep Log::Report::Message
exceptions alive for dispatchers in the main script.
- ownership of workdir to runtime user.
version 0.92: Tue Oct 15 12:22:13 CEST 2013
Fixes:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/BitTorrent.pm view on Meta::CPAN
remote_requests => [],
local_choked => 1,
local_interested => 0,
local_requests => [],
timeout => AE::timer(20, 0, sub { $s->_del_peer($h) }),
keepalive => AE::timer(
30, 120,
sub {
$s->_send_encrypted($h, build_keepalive());
}
),
# BEP06
local_allowed => [],
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Campfire/Stream.pm view on Meta::CPAN
URI->new("https://streaming.campfirenow.com/room/$room/live.json");
http_request(
'GET',
$uri,
headers => \%headers,
keepalive => 1,
want_body_handle => 1,
on_header => $on_header,
$callback,
);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/ClickHouse.pm view on Meta::CPAN
http_request
POST => $param->{uri}->as_string(),
body => $data,
headers => $headers,
persistent => 1,
keepalive => 1,
sub {
my $data = shift;
my $hdr = shift;
my $status = $hdr->{Status};
lib/AnyEvent/ClickHouse.pm view on Meta::CPAN
http_request
GET => $param->{uri}->as_string(),
headers => $headers,
persistent => 1,
keepalive => 1,
sub {
my $data = shift;
my $hdr = shift;
my $status = $hdr->{Status};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Connection.pm view on Meta::CPAN
connected => sub {
my ($client,$connection,$host,$port) = @_;
# ...
$client->after(
$interval, sub {
# Called after interval, if connection still alive
}
);
}
connfail = sub {
my ($client,$reason) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/CouchDB/Stream.pm view on Meta::CPAN
my $since = delete $args{since} || 0;
my $on_change = delete $args{on_change};
my $heartbeat = delete $args{heartbeat} || 5000;
my $on_error = delete $args{on_error} || sub { die @_ };
my $on_eof = delete $args{on_eof} || sub { };
my $on_keepalive = delete $args{on_keepalive} || sub { };
my $headers = delete $args{headers}
|| { 'Content-Type' => 'application/json' };
my $include_docs = delete $args{include_docs};
my $uri = URI->new($server);
lib/AnyEvent/CouchDB/Stream.pm view on Meta::CPAN
# some weird characters show up
# in between the JSON objects.
};
}
else {
$on_keepalive->();
}
$handle->push_read( line => $reader );
};
$handle->push_read( line => $reader );
$self->{guard} = AnyEvent::Util::guard {
lib/AnyEvent/CouchDB/Stream.pm view on Meta::CPAN
database => 'test',
on_change => sub {
my $change = shift;
warn "document $change->{_id} updated";
},
on_keepalive => sub {
warn "ping\n";
},
timeout => 1,
);
lib/AnyEvent/CouchDB/Stream.pm view on Meta::CPAN
=item B<on_change>
A code ref to execute when a change notification is received. It is mandatory.
=item B<on_keepalive>
A code ref to execute when keepalive is called.
=item B<on_error>
A code ref to execute on error. Code ref is passed the error message.
view all matches for this distribution
view release on metacpan or search on metacpan
=item timeout => $seconds
The timeout, in seconds, after which a connection error is assumed when
there is no activity. Default is C<7200>, i.e. two hours.
=item keepalive => $seconds
The interval, in seconds, at which keepalive messages will be
sent. Default is C<540>, i.e. nine minutes.
These keepalive messages are useful both to detect that a connection is
no longer working and to keep any (home) routers from expiring their
masquerading entry.
=item on_eof => $callback->($fcp)
my $self = bless {
host => $ENV{FREDHOST} || "127.0.0.1",
port => $ENV{FREDPORT} || 9481,
timeout => 3600 * 2,
keepalive => 9 * 60,
name => time.rand.rand.rand, # lame
@_,
queue => [],
req => {},
prefix => "..:aefcpid:$rand:",
}, $class;
{
Scalar::Util::weaken (my $self = $self);
$self->{kw} = AE::timer $self->{keepalive}, $self->{keepalive}, sub {
$self->{hdl}->push_write ("\n");
};
our $ENDMESSAGE = qr<\012(EndMessage|Data)\012>;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/FDpasser.pm view on Meta::CPAN
}
} elsif ($rv == 0) {
$self->error('sendmsg wrote 0 bytes');
} else {
$fh_to_send->[1]->();
## Don't do a close($fh_to_send->[0]) because the program may wish to keep it alive
undef $fh_to_send;
$self->{owatcher} = undef;
$self->try_to_send;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/FIFO.pm view on Meta::CPAN
=item $cb
The callback to be executed. Receives a "guard" object, and a list of arguments, as specied in @args.
$guard is the actually trigger that kicks the next callback to be executed, so you should keep it "alive" while you need it. For example, if you need to make an http request to declare the callback done, you should do something like this:
$fifo->push( sub {
my ($guard, @args) = @_;
http_get $uri, sub {
view all matches for this distribution
view release on metacpan or search on metacpan
->fork
->AnyEvent::Fork::RPC::run ($function,
@rpc,
on_event => sub {
if (@_ == 3 && $_[0] eq $magic0 && $_[2] eq $magic1) {
$destroy_guard if 0; # keep it alive
$_[1] eq "quit" and $stop_worker->($proc);
return;
}
$start_worker->()
while @pool < $idle;
sub {
$shutdown_guard if 0; # keep it alive
$start_worker->()
unless @pool;
push @queue, [@_];
view all matches for this distribution
view release on metacpan or search on metacpan
$id = ($id == 0xffffffff ? 0 : $id) + 1;
$id = ($id == 0xffffffff ? 0 : $id) + 1 while exists $rcb{$id}; # rarely loops
$rcb{$id} = pop;
$guard if 0; # keep it alive
$wbuf .= pack "NN/a*", $id, &$f;
$ww ||= $fh && AE::io $fh, 1, $wcb;
}
: sub {
push @rcb, pop;
$guard; # keep it alive
$wbuf .= pack "N/a*", &$f;
$ww ||= $fh && AE::io $fh, 1, $wcb;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Gearman/Client.pm view on Meta::CPAN
if $self->prefix;
my $task = AnyEvent::Gearman::Task->new( $function, $workload, %cb );
my $retry; ($retry = sub {
my @js = grep { $_->alive } @{ $self->job_servers };
unless (@js) {
$task->event( on_fail => 'no server available' );
undef $retry;
return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/HTTP/LWP/UserAgent.pm view on Meta::CPAN
recurse => 0, # because LWP call simple_request as much as needed
timeout => $self->timeout,
);
if ($self->conn_cache) {
$args{persistent} = 1;
$args{keepalive} = 1;
} else {
# By default AnyEvent::HTTP set persistent = 1 for idempotent
# requests. So just for compatibility with LWP::UserAgent we
# disable this options.
$args{persistent} = 0;
$args{keepalive} = 0;
}
return ($method, \$uri, \%args);
}
sub request_async
view all matches for this distribution
view release on metacpan or search on metacpan
Executes a HTTP request of type C<$method> (e.g. C<GET>, C<POST>). The URL
must be an absolute http or https URL.
When called in void context, nothing is returned. In other contexts,
C<http_request> returns a "cancellation guard" - you have to keep the
object at least alive until the callback get called. If the object gets
destroyed before the callback is called, the request will be cancelled.
The callback will be called with the response body data as first argument
(or C<undef> if an error occurred), and a hash-ref with response headers
(and trailers) as second argument.
your request or not.
When reusing an existent connection, many parameters (such as TLS context)
will be ignored. See the C<sessionid> parameter for a workaround.
=item keepalive => $boolean
Only used when C<persistent> is also true. This parameter decides whether
C<http_request> tries to handshake a HTTP/1.0-style keep-alive connection
(as opposed to only a HTTP/1.1 persistent connection).
The default is true, except when using a proxy, in which case it defaults
to false, as HTTP/1.0 proxies cannot support this in a meaningful way.
redo if /\G\s*,/gc;
}
}
#############################################################################
# keepalive/persistent connection cache
# fetch a connection from the keepalive cache
sub ka_fetch($) {
my $ka_key = shift;
my $hdl = pop @{ $KA_CACHE{$ka_key} }; # currently we reuse the MOST RECENTLY USED connection
delete $KA_CACHE{$ka_key}
$hdr{"content-length"} = length $arg{body}
if length $arg{body} || $method ne "GET";
my $idempotent = $IDEMPOTENT{$method};
# default value for keepalive is true iff the request is for an idempotent method
my $persistent = exists $arg{persistent} ? !!$arg{persistent} : $idempotent;
my $keepalive = exists $arg{keepalive} ? !!$arg{keepalive} : !$proxy;
my $was_persistent; # true if this is actually a recycled connection
# the key to use in the keepalive cache
my $ka_key = "$uscheme\x00$uhost\x00$uport\x00$arg{sessionid}";
$hdr{connection} = ($persistent ? $keepalive ? "keep-alive, " : "" : "close, ") . "Te"; #1.1
$hdr{te} = "trailers" unless exists $hdr{te}; #1.1
my %state = (connect_guard => 1);
my $ae_error = 595; # connecting
}
}
my $finish = sub { # ($data, $err_status, $err_reason[, $persistent])
if ($state{handle}) {
# handle keepalive
if (
$persistent
&& $_[3]
&& ($hdr{HTTPVersion} < 1.1
? $hdr{connection} =~ /\bkeep-?alive\b/i
: $hdr{connection} !~ /\bclose\b/i)
) {
ka_store $ka_key, delete $state{handle};
} else {
# no keepalive, destroy the handle
$state{handle}->destroy;
}
}
%state = ();
$_[0]->on_read (sub { });
}
}
};
# if keepalive is enabled, then the server closing the connection
# before a response can happen legally - we retry on idempotent methods.
if ($was_persistent && $idempotent) {
my $old_eof = $hdl->{on_eof};
$hdl->{on_eof} = sub {
_destroy_state %state;
_get_slot $uhost, sub {
$state{slot_guard} = shift;
return unless $state{connect_guard};
# try to use an existing keepalive connection, but only if we, ourselves, plan
# on a keepalive request (in theory, this should be a separate config option).
if ($persistent && $KA_CACHE{$ka_key}) {
$was_persistent = 1;
$state{handle} = ka_fetch $ka_key;
# $state{handle}->destroyed
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/HTTPD/SendMultiHeaderPatch.pm view on Meta::CPAN
header_set ($hdr, 'Expires' => header_get ($hdr, 'Date'))
unless header_exists ($hdr, 'Expires');
header_set ($hdr, 'Cache-Control' => "max-age=0")
unless header_exists ($hdr, 'Cache-Control');
header_set ($hdr, 'Connection' =>
($self->{keep_alive} ? 'Keep-Alive' : 'close'));
header_set ($hdr, 'Content-Length' => length "$content")
unless header_exists ($hdr, 'Content-Length')
|| ref $content;
unless (defined header_get ($hdr, 'Content-Length')) {
# keep alive with no content length will NOT work.
delete $self->{keep_alive};
header_set ($hdr, 'Connection' => 'close');
}
while (my ($h, $v) = each %$hdr) {
next unless defined $v;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/HTTPD.pm view on Meta::CPAN
=over 4
=item * support for GET and POST requests.
=item * support for HTTP 1.0 keep-alive.
=item * processing of C<x-www-form-urlencoded> and C<multipart/form-data> (C<multipart/mixed>) encoded form parameters.
=item * support for streaming responses.
lib/AnyEvent/HTTPD.pm view on Meta::CPAN
=back
=head1 ACKNOWLEDGEMENTS
Andrey Smirnov - for keep-alive patches.
Pedro Melo - for valuable input in general and patches.
Nicholas Harteau - patch for ';' pair separator support,
patch for allowed_methods support
Chris Kastorff - patch for making default headers removable
and more fault tolerant w.r.t. case.
view all matches for this distribution
view release on metacpan or search on metacpan
In the last form (message), a message of the form C<$rcvport, @msg,
@reason> will be C<snd>.
Monitoring-actions are one-shot: once messages are lost (and a monitoring
alert was raised), they are removed and will not trigger again, even if it
turns out that the port is still alive.
As a rule of thumb, monitoring requests should always monitor a remote
port locally (using a local C<$rcvport> or a callback). The reason is that
kill messages might get lost, just like any other message. Another less
obvious reason is that even monitoring requests can get lost (for example,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MQTT.pm view on Meta::CPAN
socket => undef,
host => '127.0.0.1',
port => '1883',
timeout => 30,
wait => 'nothing',
keep_alive_timer => 120,
qos => MQTT_QOS_AT_MOST_ONCE,
message_id => 1,
user_name => undef,
password => undef,
tls => undef,
lib/AnyEvent/MQTT.pm view on Meta::CPAN
$self->_send(message_type => MQTT_DISCONNECT, cv => $cv);
}
delete $self->{handle};
delete $self->{connected};
delete $self->{wait};
delete $self->{_keep_alive_handle};
delete $self->{_keep_alive_waiting};
$self->{write_queue} = [];
}
sub _error {
my ($self, $fatal, $message, $reconnect) = @_;
lib/AnyEvent/MQTT.pm view on Meta::CPAN
{
expect => $expect,
message => $args,
cv => $cv,
timeout =>
AnyEvent->timer(after => $self->{keep_alive_timer},
cb => subname 'ack_timeout_for_'.$mid =>
sub {
print ref $self, " timeout waiting for ",
message_type_string($expect), "\n" if DEBUG;
delete $self->{inflight}->{$mid};
lib/AnyEvent/MQTT.pm view on Meta::CPAN
($msg, $cv) = @_;
} else {
my $args = shift @{$self->{write_queue}} or return;
($msg, $cv) = @$args;
}
$self->_reset_keep_alive_timer();
print STDERR "Sending: ", $msg->string, "\n" if DEBUG;
$self->{message_log_callback}->('>', $msg) if ($self->{message_log_callback});
$self->{_waiting} = [$msg, $cv];
print ' ', (unpack 'H*', $msg->bytes), "\n" if DEBUG;
$self->{handle}->push_write($msg->bytes);
$cv;
}
sub _reset_keep_alive_timer {
my ($self, $wait) = @_;
undef $self->{_keep_alive_handle};
my $method = $wait ? '_keep_alive_timeout' : '_send_keep_alive';
$self->{_keep_alive_waiting} = $wait;
my $weak_self = $self;
weaken $weak_self;
$self->{_keep_alive_handle} =
AnyEvent->timer(after => $self->{keep_alive_timer},
cb => subname((substr $method, 1).'_cb' =>
sub { $weak_self->$method(@_) }));
}
sub _send_keep_alive {
my $self = shift;
print STDERR "Sending: keep alive\n" if DEBUG;
$self->_send(message_type => MQTT_PINGREQ);
$self->_reset_keep_alive_timer(1);
}
sub _keep_alive_timeout {
my $self = shift;
print STDERR "keep alive timeout\n" if DEBUG;
undef $self->{_keep_alive_waiting};
$self->{handle}->destroy;
$self->_error(0, 'keep alive timeout', 1);
}
sub _keep_alive_received {
my $self = shift;
print STDERR "keep alive received\n" if DEBUG;
return unless (defined $self->{_keep_alive_waiting});
$self->_reset_keep_alive_timer();
}
sub connect {
my ($self, $msg, $cv) = @_;
lib/AnyEvent/MQTT.pm view on Meta::CPAN
# call user-defined on_connect function.
$weak_self->{on_connect}->($handle, $retry) if $weak_self->{on_connect};
my $msg =
Net::MQTT::Message->new(
message_type => MQTT_CONNECT,
keep_alive_timer => $weak_self->{keep_alive_timer},
client_id => $weak_self->{client_id},
clean_session => $weak_self->{clean_session},
will_topic => $weak_self->{will_topic},
will_qos => $weak_self->{will_qos},
will_retain => $weak_self->{will_retain},
lib/AnyEvent/MQTT.pm view on Meta::CPAN
delete $self->{_sub_reconnect};
return
}
sub _process_pingresp {
shift->_keep_alive_received();
}
sub _process_suback {
my ($self, $handle, $msg, $error) = @_;
print STDERR "Confirmed subscription:\n", $msg->string(' '), "\n" if DEBUG;
lib/AnyEvent/MQTT.pm view on Meta::CPAN
=item C<timeout>
The timeout for responses from the server.
=item C<keep_alive_timer>
The keep alive timer.
=item C<user_name>
The user name for the MQTT broker.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Mattermost.pm view on Meta::CPAN
=head2 ping
$mconn->ping();
Pings the Mattermost server over the WebSocket connection to maintain online
status and ensure the connection remains alive. You should not have to call
this method yourself, as start() sets up a ping callback on a timer for you.
=cut
sub ping {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MultiDownload.pm view on Meta::CPAN
my $ev; $ev = http_get $url,
timeout => $self->timeout,
recurse => $self->recurse,
persistent => 1,
keepalive => 1,
headers => {
%{ $self->headers },
Range => $task->{range}
},
on_body => $self->on_body($task),
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MySQL.pm view on Meta::CPAN
};
$next_act->();
});
}
=head2 $dbh->ping(sub {my $alive = shift;});
=cut
sub ping {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
view all matches for this distribution
view release on metacpan or search on metacpan
0.34 Sun Sep 10 07:27:06 BST 2006
- added next marker and more docs from Jesse Vincent
0.33 Sat Aug 26 16:26:37 BST 2006
- documentation and test cleanup from Jesse Vincent
- use HTTP keep alive (patch by Scott Gifford)
- remove ununused code in _make_request (patch by Scott Gifford)
0.32 Tue Apr 25 19:51:06 BST 2006
- fix bug with listing buckets with parameters (thanks to karjala)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Pg/Pool.pm view on Meta::CPAN
=item connection_retries => $n
Maximum number of attempts to establish a new database connection
before calling the C<on_connect_error> callback when there is no other
connection alive on the pool.
=item connection_delay => $seconds
When establishing a new connection fails, this setting allows to
configure the number of seconds to delay before trying to connect
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent.pm view on Meta::CPAN
# });
#
# sub {
# return 0 unless $$renabled;
#
# $guard if 0; # keep guard alive, but don't cause runtime overhead
# require AnyEvent::Log unless $AnyEvent::Log::VERSION;
# package AnyEvent::Log;
# _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time
# }
}
view all matches for this distribution