view release on metacpan or search on metacpan
t/00-load.t view on Meta::CPAN
}
require_ok $pkg;
dies_ok { $pkg->new( fmt => 'endnote' ) } "die of missing arguments";
dies_ok {$pkg->new(id => '811388', fmt => 'mods')} "invalid format";
lives_ok { $pkg->new( doi => '10.1088/1126-6708/2009/03/112' ) } "I'm alive";
lives_ok { $pkg->new( id => '811388' ) } "I'm alive";
lives_ok { $pkg->new( query => "hadronization" ) } "I'm alive";
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Importer/OAI.pm view on Meta::CPAN
} or croak $@;
}
sub _build_oai {
my ($self) = @_;
my $agent = HTTP::OAI::Harvester->new(baseURL => $self->url, resume => 0, keep_alive => 1);
if( $self->has_username && $self->has_password ) {
my $uri = URI->new( $self->url );
my @credentials = (
$uri->host_port,
$self->realm || undef,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Store/Solr.pm view on Meta::CPAN
my $hits = $store->bag->search(query => 'name:Patrick');
=cut
has url => (is => 'ro', default => sub {'http://localhost:8983/solr'});
has keep_alive => (is => 'ro', default => sub {0});
has solr => (is => 'lazy');
has bag_key => (is => 'lazy', alias => 'bag_field');
has on_error => (
is => 'ro',
isa => sub {
lib/Catmandu/Store/Solr.pm view on Meta::CPAN
WebService::Solr->new(
$_[0]->url,
{
autocommit => 0,
default_params => {wt => 'json'},
agent => LWP::UserAgent->new(keep_alive => $self->keep_alive),
}
);
}
sub _build_bag_key {
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-store.t view on Meta::CPAN
isnt $bag->count, 1, "Count bag size";
$bag->add({ _id => '123' , foo => "bar"});
my $bag2 = $store->bag;
is $bag2->count , 1 , "Bags stay alive";
my $bag3 = $store->bag('foo');
ok ! $bag3->get('123') , "foo doesnt have 123";
done_testing 27;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catmandu/Store/Datahub/API.pm view on Meta::CPAN
builder => '_build_access_token'
);
sub _build_client {
my $self = shift;
return LWP::UserAgent->new(keep_alive => 1);
}
sub _build_access_token {
my $self = shift;
return $self->generate_token();
view all matches for this distribution
view release on metacpan or search on metacpan
src/matcher.h view on Meta::CPAN
uint32_t pattern;
int sline;
int eline;
};
// RAII read-only mmap of a file. munmaps on destruction; keeps a Segment's backing memory alive.
class MappedFile {
public:
MappedFile() = default;
~MappedFile();
bool map(const std::string& path);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Centrifugo/Client.pm view on Meta::CPAN
$cclient->subscribe( channel => 'my-channel&' );
$cclient->subscribe( channel => 'public-channel' );
$cclient->subscribe( channel => '$private' );
# Now start the event loop to keep the program alive
AnyEvent->condvar->recv;
=head1 DESCRIPTION
This library allows to communicate with Centrifugo through a websocket.
lib/Centrifugo/Client.pm view on Meta::CPAN
my $client = Centrifugo::Client->new( $URL,
debug => 'true', # If true, some informations are written on STDERR
debug_ws => 'true', # If true, all web socket messages are written on STDERR
authEndpoint => "...", # The full URL used to ask for a key to subscribe to private channels
max_alive_period => 30, # interval (in s) since last communication with server that triggers a PING (default 0)
refresh_period => 5, # Check frequency for max_alive_period (default 10s)
retry => 0.5 , # interval (in ms) between reconnect attempts which value grows exponentially (default 1.0)
max_retry => 30, # upper interval value limit when reconnecting. (default 30)
resubscribe => 'true', # automatic resubscribing on subscriptions (default: 'true')
recover => 'true', # Recovers the lost messages after a reconnection (default: 'false')
ws_params => { # These parameters are passed to AnyEvent::WebSocket::Client->new(...)
lib/Centrifugo/Client.pm view on Meta::CPAN
$this->{WS_URL} = $ws_url;
$this->{DEBUG} = $params{debug} && $params{debug}!~/^(0|false|no)$/i; delete $params{debug};
$this->{DEBUG_WS} = $params{debug_ws} && $params{debug_ws}!~/^(0|false|no)$/i; delete $params{debug_ws};
$this->{AUTH_URL} = delete $params{authEndpoint} || "/centrifuge/auth/";
$this->{WEBSOCKET} = AnyEvent::WebSocket::Client -> new( %{$params{ws_params}} ); delete $params{ws_params};
$this->{MAX_ALIVE} = delete $params{max_alive_period} || 0;
$this->{REFRESH} = delete $params{refresh_period} || 10;
$this->{RETRY} = delete $params{retry} || 1;
$this->{MAX_RETRY} = delete $params{max_retry} || 30;
$this->{RESUBSCRIBE} = ! defined $params{resubscribe} || $params{resubscribe}!~/^(0|false|no)$/i; delete $params{resubscribe};
$this->{RECOVER} = $params{recover} && $params{recover}!~/^(0|false|no)$/i; delete $params{recover};
lib/Centrifugo/Client.pm view on Meta::CPAN
# on Connect, the client_id must be read (if available)
if ($body && ref($body) eq 'HASH' && $body->{client}) {
$this->{CLIENT_ID} = $body->{client};
$this->_debug( "Centrifugo::Client : CLIENT_ID=".$this->{CLIENT_ID} );
}
$this->_init_keep_alive_timer() if $this->{MAX_ALIVE};
$this->_reset_reconnect_sequence();
$this->_resubscribe() if $this->{RESUBSCRIBE};
}
# This function is called when client receives a message
lib/Centrifugo/Client.pm view on Meta::CPAN
sub _on_close {
my ($this, $message) = @_;
$message="(none)" unless $message;
$this->_debug( "Centrifugo::Client : Connection closed, reason=$message" );
$this->{ON}->{'ws_closed'}->($message) if $this->{ON}->{'ws_closed'};
undef $this->{_alive_handler};
undef $this->{WSHANDLE};
undef $this->{CLIENT_ID};
delete $this->{_subscribed_channels};
delete $this->{_pending_subscriptions};
$this->_reconnect();
lib/Centrifugo/Client.pm view on Meta::CPAN
# This function is called once for each message received from Centrifugo
sub _on_ws_message {
my ($this, $message) = @_;
$this->_debug_ws("Send > WebSocket : $message->{body}");
$this->{_last_alive_message} = time();
my $fullbody = decode_json($message->{body}); # The body of websocket message
# Handle a body containing {response} : converts into a singleton
if (ref($fullbody) eq 'HASH') {
$fullbody = [ $fullbody ];
}
lib/Centrifugo/Client.pm view on Meta::CPAN
}
);
}
# Creates the timer to send periodic ping
sub _init_keep_alive_timer {
my ($this) = @_;
$this->{_alive_handler} = AnyEvent->timer(
after => $this->{REFRESH},
interval => $this->{REFRESH},
cb => sub {
my $late = time() - $this->{_last_alive_message};
if ($late > $this->{MAX_ALIVE}) {
$this->_debug( "Sending ping (${late}s without message)" );
$this->ping();
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Cfn/Resource/AWS/CloudFront/Distribution.pm view on Meta::CPAN
use MooseX::StrictConstructor;
extends 'Cfn::Value::TypedValue';
has HTTPPort => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
has HTTPSPort => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
has OriginKeepaliveTimeout => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
has OriginProtocolPolicy => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, required => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
has OriginReadTimeout => (isa => 'Cfn::Value::Integer', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
has OriginSSLProtocols => (isa => 'Cfn::Value::Array|Cfn::Value::Function|Cfn::DynamicValue', is => 'rw', coerce => 1, traits => [ 'CfnMutability' ], mutability => 'Mutable');
}
view all matches for this distribution
view release on metacpan or search on metacpan
examples/capitals.pl view on Meta::CPAN
# Read the content
my $line;
my $n = $self->http->read_entity_body($line, 1024);
$content .= $line;
if ($self->http->keep_alive) {
# In the case where the HTTP request has keep-alive we need to see if the
# content has all arrived as read_entity_body() will not tell when the end
# of the content has been reached.
return TRUE unless length($content) == $headers{'Content-Length'};
}
elsif ($n) {
view all matches for this distribution
view release on metacpan or search on metacpan
examples/splash_example.pl view on Meta::CPAN
# (setActivationPolicy, finishLaunching, etc.) which is required
# before any child windows will display.
my $wv = $app->webview;
$wv->init;
# Non-blocking event loop pump - call repeatedly to keep GUI alive
sub pump { $wv->loop(0) for 1..5 }
# Pump + sleep helper
sub pump_sleep {
my ($secs) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
agent/skills/chorus-create-project.md view on Meta::CPAN
---
## Phase 0 â Read the KB (single source)
### 0.0 Sandbox inventory (first tool call â token keepalive)
**Before reading any file**, read the directory tree $SANDBOX/` immediately.
This serves two purposes:
1. Acquires the full sandbox structure early (agents list, rules dirs, existing JSON files)
agent/skills/chorus-create-project.md view on Meta::CPAN
keeping the IDE token active from the very start.
Use this inventory to:
- Confirm the list of `<slug>.org` files to read in 0.2
- Detect any existing `projet-*.json` file (for Phase 0.3)
- Know which `rules/<slug>/` directories exist (for the keepalive calls in 0.2)
### 0.1 Pipeline index
Read `$SANDBOX/agent/chorus/index.org`:
- Perl namespace of the project
agent/skills/chorus-create-project.md view on Meta::CPAN
### 6.1 `--batch` â Orchestrator workflow
#### Step 1 â Run Phases 0+1
Run Phase 0 in full (inventory + KB reading + keepalives) and Phase 1 (coverage table).
Do NOT generate any JSON here â stop after the coverage table is built.
#### Step 2 â Build the compact KB summary
Distil the KB into a self-contained block (⤠60 lines).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Cisco/Accounting.pm view on Meta::CPAN
}
}
##
## Send a keepalive (new line character), do not do any error checking here
## Useful if 'persistent' is enabled, but still it's up to you to call the keepalive in time before session times out
##
sub keepalive() {
my ($self) = shift;
if ($self->{'session'}) {
eval {
$self->{'session'}->cmd(" ");
lib/Cisco/Accounting.pm view on Meta::CPAN
totalpackets total number of packets seen for every time do_accounting() was called
totalpolledlines total number of lines that was parsed and aggregated
totalskippedlines total number of lines that were skipped (headers etc.)
uniquehostpairs total number of unique host pairs that were seen
=item keepalive()
If you have a persistent connection but you're only calling do_accounting() every 5 minutes for example then you might receive
a connection timeout.
This can be solved by sending a keepalive every 30 seconds for example.
The keepalive just sends a newline character to the remote host avoiding a connection timeout.
$acct->keepalive()
=back
=head1 SUPPORTED DEVICES
view all matches for this distribution
view release on metacpan or search on metacpan
t/indentbug.t view on Meta::CPAN
! Last configuration change at 22:19:05 GMT Wed Jun 4 2003 by xyz
! NVRAM config last updated at 22:19:05 GMT Wed Jun 4 2003 by xyz
!
version 12.2
no service pad
service tcp-keepalives-in
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
service compress-config
!
view all matches for this distribution
view release on metacpan or search on metacpan
Citrix/SessionSet.pm view on Meta::CPAN
# Added loading of Net::Ping to circumvent
eval {require(Net::Ping);};
if ($@) {} # print("Dont have Net::Ping (risk hanging)");
else {
my $p = Net::Ping->new();
if ($p->ping($usehost)) {if ($trace) {print("$usehost is alive (reachable by PING).\n");}}
# Reuse $tout as state variable
else {$tout = 0;}
$p->close();
if (!$tout) {$ss->{'msg'} = "$usehost NOT Alive.\n";return(1);}
}
view all matches for this distribution
view release on metacpan or search on metacpan
}
made:
h = newHV();
(void)hv_stores(h, "_ptr", newSViv(PTR2IV(sc)));
/* Hold the source alive for as long as the scan can read it. */
if (keep) (void)hv_stores(h, "_keep", newSVsv(keep));
RETVAL = sv_bless(newRV_noinc((SV *)h),
gv_stashpvs("ClamAV::Clamd::Scan", GV_ADD));
OUTPUT:
RETVAL
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ClamAV/Client.pm view on Meta::CPAN
my $scanner = ClamAV::Client->new(
socket_host => '127.0.0.1',
socket_port => 3310
);
die("ClamAV daemon not alive")
if not defined($scanner) or not $scanner->ping();
=head2 Daemon maintenance
my $version = $scanner->version;
lib/ClamAV/Client.pm view on Meta::CPAN
=over
=item B<ping>: RETURNS SCALAR; THROWS ClamAV::Client::Error
Returns B<true> ('PONG') if the ClamAV daemon is alive. Throws a
ClamAV::Client::Error exception otherwise.
=cut
sub ping {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Clamd.pm view on Meta::CPAN
return bless \%options, $class;
}
=head2 ping()
Pings the clamd to check it is alive. Returns true if it is
alive, false if it is dead. Note that it is still possible for
a race condition to occur between your test for ping() and
any call to scan(). See below for more details.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
t/edge_cases.t view on Meta::CPAN
my $weak = $strong;
weaken($weak);
diag 'weak ref: ' . (defined($weak) ? ref($weak) : 'undef') if $ENV{TEST_VERBOSE};
# $weak is still alive because $strong holds a strong reference
ok defined($weak) && blessed($weak),
'precondition: weakened ref is still alive (strong ref holds it)';
# A live weakened blessed ref must be accepted by new()
lives_ok { $strong->new() }
'live weakened blessed ref: new() succeeds via strong ref';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/DBI/ViewLoader.pm view on Meta::CPAN
# disconnect current DBI handle, if any
sub _clear_dbi_handle {
my $self = shift;
return $self if $self->_keepalive;
if (defined $self->{_dbh}) {
delete($self->{_dbh})->disconnect;
}
lib/Class/DBI/ViewLoader.pm view on Meta::CPAN
$self->_clear_dbi_handle;
}
# switch to disable _clear_dbi_handle
sub _set_keepalive {
my $self = shift;
$self->{__keepalive} = shift;
return $self;
}
# check status of switch
sub _keepalive {
my $self = shift;
return $self->{__keepalive};
}
=head2 set_namespace
$obj = $obj->set_namespace($namespace)
lib/Class/DBI/ViewLoader.pm view on Meta::CPAN
This is the cleanup method for the object's DBI handle. It is called whenever
the DBI handle needs to be closed down. i.e. when a new handle is used or the
object goes out of scope. Subclasses should override this method if they need to
clean up any state data that relies on the current database connection, like
statement handles for example. If you don't want the handle that the object is
using to be disconnected, use the _set_keepalive method.
sub _clear_dbi_handle {
my $self = shift;
delete $self->{statement_handle};
lib/Class/DBI/ViewLoader.pm view on Meta::CPAN
This method is used to attach a DBI handle to the object. It might prove useful
to use this method in order to use an existing database connection in the loader
object. Note that unlike set_dsn, calling this method directly will not cause an
appropriate driver to be loaded. See _load_driver for that.
=head2 _set_keepalive
$obj = $obj->_set_keepalive($bool)
When set to true, the database handle used by the object won't be disconnected automatically.
=head2 _load_driver
view all matches for this distribution
view release on metacpan or search on metacpan
During programming I'm sometimes looking for an uncommon solution.
Before it becomes realized it is often not needed anymore, because there
is another way to do it, but the idea is still alive and to wants become real.
The result of one similar situation is this module and now it is possible
to have local Class::Data I will use from time to time.
Maybe someone else has a practical use for this too.
view all matches for this distribution
view release on metacpan or search on metacpan
CHANGELOG
v2.01 (2019/05/24)
==================
--Typos in documentation (Debian Perl Group)
--Conceiving a child would leave an errant object alive even
if it failed initialization. This is fixed.
v2.00 (2017/01/23)
==================
--Complete rewrite
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/VitalStatus.pm view on Meta::CPAN
use warnings;
package VitalStatus;
use Exporter qw( import );
use Class::Enumeration::Builder { predicate => 1 }, qw( dead alive );
1
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Meta.pm view on Meta::CPAN
use Class::Meta::Types::Perl 'semi-affordance';
The boolean data type is the only one that uses a slightly different approach
to the creation of affordance accessors: It creates three of them. Assuming
you're creating a boolean attribute named "alive", it will create these
accessors:
sub is_alive { shift->{alive} }
sub set_alive_on { shift->{alive} = 1 }
sub set_alive_off { shift->{alive} = 0 }
Incidentally, I stole the term "affordance" from Damian Conway's "Object
Oriented Perl," pp 83-84, where he borrows it from Donald Norman.
See L<Class::Meta::Type|Class::Meta::Type> for details on creating new data
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Test/More.pm view on Meta::CPAN
This declares a block of tests to skip, why and under what conditions
to skip them. An example is the easiest way to illustrate:
skip {
ok( head("http://www.foo.com"), "www.foo.com is alive" );
ok( head("http://www.foo.com/bar"), " and has bar" );
} 2, "LWP::Simple not installed",
!eval { require LWP::Simple; LWP::Simple->import; 1 };
The $if condition is optional, but $why is not.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Rebirth.pm view on Meta::CPAN
# Andreas Hernitscheck ahernit(AT)cpan.org
# @brief Takes a death object and and creates a living object of it.
# Such a zombie class looks like a normal class when you dump it.
# But it is not alive, means methods won't work. An Effect which
# happens by deserializing classes from a store (dumped data).
sub rebirth { # $object ($zombie)
my $zombie = shift or croak "requires zombie";
my $obj;
lib/Class/Rebirth.pm view on Meta::CPAN
my $object = rebirth($zombie);
Takes a death object and and creates a living object of it.
Such a zombie class looks like a normal class when you dump it.
But it is not alive, means methods won't work. An effect which
happens by deserializing classes from a store (dumped data).
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
t/integration.t view on Meta::CPAN
diag sprintf('[hash:lifecycle] store keys: %s', join(', ', sort keys %store))
if $ENV{TEST_VERBOSE};
# DESTROY fires when $obj goes out of scope; use a block to force it.
{ my $tmp = $obj; } # keeps $obj alive; we destroy via explicit undef
$obj = undef;
is(scalar(keys %store), 0,
'hash:lifecycle: DESTROY removes all cache entries from the hash ref');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Class/Simple/Readonly/Cached.pm view on Meta::CPAN
# has been freed (global destruction), there is no object to delegate to.
# Conclusion: fall back to UNIVERSAL for what this package directly provides.
return $self->SUPER::can($method)
if !ref($self) || !ref($self->{object});
# Premise: $self->{object} is alive and is a valid reference (Invariant I4).
# Conclusion: delegate to the inner object first; fall back to UNIVERSAL.
return $self->{object}->can($method) // $self->SUPER::can($method);
}
=head2 isa
view all matches for this distribution
view release on metacpan or search on metacpan
eg/migrate_with_transform.pl view on Meta::CPAN
return undef if !defined $row->[0];
$row->[1] = uc($row->[1]) if defined $row->[1];
return $row;
};
# Long-lived sink: bulk_inserter pools an HTTP::Tiny with keep-alive
# and auto-flushes at batch_size.
my $bi = ClickHouse::Encoder->bulk_inserter(
host => $dst_host, port => $dst_port,
table => $dst_tbl,
columns => \@columns,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ClickHouse.pm view on Meta::CPAN
'_host' => 'localhost',
'_port' => 8123,
'_database' => 'default',
'_user' => '',
'_password' => '',
'_keep_alive' => 1,
'_format' => 'TabSeparated',
'_socket' => undef,
'_uri' => undef,
'_timeout' => 30,
);
lib/ClickHouse.pm view on Meta::CPAN
# create Net::HTTP object
my $socket = Net::HTTP->new(
'Host' => $self->{'_host'},
'PeerPort' => $self->{'_port'},
'HTTPVersion' => '1.1',
'KeepAlive' => $self->{'_keep_alive'},
'Timeout' => $self->{'_timeout'},
) or die "Can't connect: $@";
# create URI object
lib/ClickHouse.pm view on Meta::CPAN
sub DESTROY {}
sub disconnect {
my ($self) = @_;
if (my $socket = $self->_get_socket()) {
$socket->keep_alive(0);
$self->ping();
}
return 1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/14-weakened-ref.t view on Meta::CPAN
plan tests => 16;
# GH #15 - Weakened refs always clone as undef
# When cloning a structure with weakened references, Clone should
# preserve the weakness and keep referents alive when strong
# references to them exist elsewhere in the clone graph.
{
package Parent;
sub new { bless { children => [] }, shift }
view all matches for this distribution