view release on metacpan or search on metacpan
lib/AnyEvent/DBI/Abstract.pm view on Meta::CPAN
for my $method (qw( select insert update delete )) {
*$method = sub {
my($self, @args) = @_;
my $cb = pop @args;
my($stmt, @bind) = $self->abstract->$method(@args);
$self->exec($stmt, @bind, $cb);
};
}
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
NEXT();
});
},
sub {
$sth = $dbh->prepare('SELECT * FROM Async WHERE id=?');
$sth->bind_param(1, 5);
$sth->execute(sub {
$res = shift;
is($res, 1, 'execute');
is_deeply($sth->fetchrow_hashref(), {id=>5,s=>'three'}, 'bind_param');
NEXT();
});
},
sub {
$sth = $dbh->prepare('INSERT INTO Async (id,s) VALUES (?,?)', {async=>0});
view all matches for this distribution
view release on metacpan or search on metacpan
t/fake-mysql view on Meta::CPAN
print localtime()." [$$] Loaded ".($#config_rules + 1)." rules from $config_name.\n" if $debug;
}
socket(SERVER_SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
setsockopt(SERVER_SOCK, SOL_SOCKET, SO_REUSEADDR, pack("l", 1));
bind(SERVER_SOCK, sockaddr_in($port, inet_aton($interface))) || die "bind: $!";
listen(SERVER_SOCK,1);
print localtime()." [$$] Note: port $port is now open on interface $interface.\n" if $debug;
while (1) {
my $remote_paddr = accept(my $remote_socket, SERVER_SOCK);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/DNS/Nameserver.pm view on Meta::CPAN
$self->{watchers} = [];
my @LocalAddr =ref $self->{LocalAddr} eq 'ARRAY'?@{$self->{LocalAddr}}:($self->{LocalAddr});
for my $la (@LocalAddr){
my $hdl;$hdl = AnyEvent::Handle::UDP->new(
bind => [$la,$self->{LocalPort}],
on_recv => sub {
my ($data, $ae_handle, $client_addr) = @_;
my $family = sockaddr_family($client_addr);
my ($peerport, $peerhost) = ( $family == AF_INET6 ) ? sockaddr_in6($client_addr) : sockaddr_in($client_addr);
$peerhost = inet_ntop($family, $peerhost);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/FDpasser.pm view on Meta::CPAN
open($fh, '+<&=', $fd) || die "couldn't open";
} else {
socket($fh, AF_UNIX, SOCK_STREAM, AF_UNSPEC) || die "Unable to create AF_UNIX socket: $!";
setsockopt($fh, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die "Unable to setsockopt(SO_REUSEADDR): $!";
unlink($path);
bind($fh, Socket::sockaddr_un($path)) || die "Unable to bind AF_UNIX socket to $path : $!";
listen($fh, $backlog) || die "Unable to listen on $path : $!";
}
return $fh;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/FTP/Server.pm view on Meta::CPAN
$AnyEvent::FTP::Server::VERSION //= 'dev';
with 'AnyEvent::FTP::Role::Event';
__PACKAGE__->define_events(qw( bind connect ));
has hostname => (
is => 'ro',
);
lib/AnyEvent/FTP/Server.pm view on Meta::CPAN
is => 'ro',
default => sub { [ 220 => "aeftpd $AnyEvent::FTP::Server::VERSION" ] },
);
has bindport => (
is => 'rw',
);
has inet => (
lib/AnyEvent/FTP/Server.pm view on Meta::CPAN
{
my($self) = @_;
my $prepare = sub {
my($fh, $host, $port) = @_;
$self->bindport($port);
$self->emit(bind => $port);
};
my $connect = sub {
my($fh, $host, $port) = @_;
lib/AnyEvent/FTP/Server.pm view on Meta::CPAN
my($code, $message) = @{ $server->welcome };
The welcome messages as key value pairs. Read only and can be overridden by
the constructor.
=head2 bindport
my $port = $server->bindport;
$server->bindport($port);
Retrieves or sets the TCP port to bind to.
=head2 inet
my $bool = $server->inet;
view all matches for this distribution
view release on metacpan or search on metacpan
for details.
# INSTALLATION
Unless your operating system is missing in the list below, you have to install
a helper module that provides the binding for the kernel filesystem watch
functionality.
If the command `cpanm` is not available on your system, see
http://www.cpan.org/modules/INSTALL.html for instructions on how to install
Perl modules.
view all matches for this distribution
view release on metacpan or search on metacpan
example/server.pl view on Meta::CPAN
use strict;
use warnings;
use AnyEvent::Finger::Server;
# bind to 79 if root, otherwise use
# an unprivilaged port
my $port = ($> && $^O !~ /^(cygwin|MSWin32)$/) ? 8079 : 79;
print "listening to port $port\n";
view all matches for this distribution
view release on metacpan or search on metacpan
These parameters are all passed more or less directly to
L<AnyEvent::Fork::RPC>. They are only briefly mentioned here, for
their full documentation please refer to the L<AnyEvent::Fork::RPC>
documentation. Also, the default values mentioned here are only documented
as a best effort - the L<AnyEvent::Fork::RPC> documentation is binding.
=over 4
=item async => $boolean (default: 0)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Graphite/SNMPAgent.pm view on Meta::CPAN
# protects against 'lame' servers
$session->timeout($self->{timeout});
for my $metric (@{$self->{hosts}{$host}}) {
$session->get_request(
-varbindlist => [$metric->{oid}],
-callback => sub {
my ($session) = @_;
my $result = $session->var_bind_list();
my $value = $result->{$metric->{oid}};
if(!defined($value)) {
warn "undefined reply from $host" . ":" . "$metric->{oid}: " . $session->error();
} else {
if($metric->{filter}) {
view all matches for this distribution
view release on metacpan or search on metacpan
unique ID will be reused.
=item on_prepare => $callback->($fh)
In rare cases you need to "tune" the socket before it is used to
connect (for example, to bind it on a given IP address). This parameter
overrides the prepare callback passed to C<AnyEvent::Socket::tcp_connect>
and behaves exactly the same way (e.g. it has to provide a
timeout). See the description for the C<$prepare_cb> argument of
C<AnyEvent::Socket::tcp_connect> for details.
view all matches for this distribution
view release on metacpan or search on metacpan
0.6 Tue Jul 14 11:16:44 CEST 2009
- fixed leaking AE::HTTPD::HTTPConnection.
0.5 Thu Jul 2 04:30:14 CEST 2009
- applied patch from mathieu at closetwork.org to add a
host parameter for binding.
- removed bogus API stuff like ::Appgets or the weird
form and response handling. AnyEvent::HTTPD should be and
stay a simple HTTP server for simple purposes.
If you need further sugar, please write your own modules for
it. If you need anything ask me or look in the git repository
view all matches for this distribution
view release on metacpan or search on metacpan
examples/anyevent-udp-server.pl view on Meta::CPAN
# Default for AnyEvent is to log nothing
$AnyEvent::Log::FILTER->level('debug');
# AE::Handle::UDP does all for us:
# be sure to use the "bind" option!
my $udp_server = AnyEvent::Handle::UDP->new(
# Bind to this host and port
bind => ['0.0.0.0', 4000],
# AnyEvent will run this callback when getting some input
on_recv => sub {
my ($data, $ae_handle, $client_addr) = @_;
chomp $data;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Handle/ZeroMQ.pm view on Meta::CPAN
use AE;
use ZeroMQ;
my $ctx = ZeroMQ::Context->new;
my $socket = $ctx->socket(ZMQ_XREP);
$socket->bind('tcp://0:8888');
my $hdl = AnyEvent::Handle::ZeroMQ->new(
socket => $socket,
on_drain => sub { print "the write queue is empty\n" },
on_error => sub { my($error_msg) = @_; ... },
view all matches for this distribution
view release on metacpan or search on metacpan
t/redis.conf.base view on Meta::CPAN
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379
port __PORT__
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for connections.
#
# bind 127.0.0.1
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 300
# Save the DB on disk:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/I3.pm view on Meta::CPAN
workspace => ($event_mask | 0),
output => ($event_mask | 1),
mode => ($event_mask | 2),
window => ($event_mask | 3),
barconfig_update => ($event_mask | 4),
binding => ($event_mask | 5),
shutdown => ($event_mask | 6),
tick => ($event_mask | 7),
_error => 0xFFFFFFFF,
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
field %workspace;
field %output;
field %mode;
field %window;
field %barconfig_update;
field %binding;
field %tick;
field %shutdown;
field @swallows;
field $c;
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
%tick = %{ delete $args->{tick} } if ref $args->{tick} eq 'HASH';
%shutdown = %{ delete $args->{shutdown} } if ref $args->{shutdown} eq 'HASH';
%output = %{ delete $args->{output} } if ref $args->{output} eq 'HASH';
%mode = %{ delete $args->{mode} } if ref $args->{mode} eq 'HASH';
%window = %{ delete $args->{window} } if ref $args->{window} eq 'HASH';
%binding = %{ delete $args->{binding} } if ref $args->{binding} eq 'HASH';
@groups = @{ delete $args->{groups} } if ref $args->{groups} eq 'ARRAY';
@swallows = @{ delete $args->{swallows} }
if ref $args->{swallows} eq 'ARRAY';
}
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
$sub->($self, $i3, $event);
}
}
);
$self->subscribe(
binding => sub {
my $event = shift;
$self->log_event('binding', $event);
my $payload = $event->{change};
if (my $sub = $binding{$payload}) {
$sub->($self, $i3, $event);
}
}
);
lib/AnyEvent/I3X/Workspace/OnDemand.pm view on Meta::CPAN
>> and leaves new workspaces for the ones you have defined.
In your C<< .config/i3/config >> you can set something like this to switch
groups:
bindsym $mod+w mode "Activities"
mode "Activities" {
bindsym 0 exec i3-msg -t send_tick group:foo; mode default
bindsym 9 exec i3-msg -t send_tick group:bar; mode default
bindsym 8 exec i3-msg -t send_tick group:baz; mode default
bindsym Return mode "default"
bindsym Escape mode "default"
}
For the user guide please refer to
L<AnyEvent::I3X::Workspace::OnDemand::UserGuide>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Ident.pm view on Meta::CPAN
# ABSTRACT: Simple asynchronous ident client and server
our $VERSION = '0.08'; # VERSION
# keep the server object in scope so that
# we don't unbind from the port. If you
# don't want this, then use the OO interface
# for ::Server instead.
my $keep = [];
sub ident_server ($$$;$)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/JSONRPC/Lite/Server.pm view on Meta::CPAN
Listening port or path to unix socket (Required)
=item address => 'Str'
Bind address. Default to undef: This means server binds all interfaces by default.
If you want to use unix socket, this option should be set to "unix/"
=item on_error => $cb->($handle, $fatal, $message)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/JSONRPC/TCP/Server.pm view on Meta::CPAN
Listening port or path to unix socket (Required)
=item address => 'Str'
Bind address. Default to undef: This means server binds all interfaces by default.
If you want to use unix socket, this option should be set to "unix/"
=item on_error => $cb->($handle, $fatal, $message)
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/CPANfile.pm view on Meta::CPAN
}
package Module::CPANfile::Environment;
use strict;
my @bindings = qw(
on requires recommends suggests conflicts
osname perl
configure_requires build_requires test_requires author_requires
);
inc/Module/CPANfile.pm view on Meta::CPAN
sub import {
my($class, $result_ref) = @_;
my $pkg = caller;
$$result_ref = Module::CPANfile::Result->new;
for my $binding (@bindings) {
no strict 'refs';
*{"$pkg\::$binding"} = sub { $$result_ref->$binding(@_) };
}
}
sub parse {
my $file = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
A node ID is a string that uniquely identifies the node within a
network. Depending on the configuration used, node IDs can look like a
hostname, a hostname and a port, or a random string. AnyEvent::MP itself
doesn't interpret node IDs in any way except to uniquely identify a node.
=item binds - C<ip:port>
Nodes can only talk to each other by creating some kind of connection to
each other. To do this, nodes should listen on one or more local transport
endpoints - binds.
Currently, only standard C<ip:port> specifications can be used, which
specify TCP ports to listen on. So a bind is basically just a tcp socket
in listening mode that accepts connections from other nodes.
=item seed nodes
When a node starts, it knows nothing about the network it is in - it
is expanded to the local nodename, C<%u> is replaced by a random
strign to make the node unique. For example, the F<aemp> commandline
utility uses C<aemp/%n/%u> as nodename, which might expand to
C<aemp/cerebro/ZQDGSIkRhEZQDGSIkRhE>.
=item step 2, bind listener sockets
The next step is to look up the binds in the profile, followed by binding
aemp protocol listeners on all binds specified (it is possible and valid
to have no binds, meaning that the node cannot be contacted from the
outside. This means the node cannot talk to other nodes that also have no
binds, but it can still talk to all "normal" nodes).
If the profile does not specify a binds list, then a default of C<*> is
used, meaning the node will bind on a dynamically-assigned port on every
local IP address it finds.
=item step 3, connect to seed nodes
As the last step, the seed ID list from the profile is passed to the
commandline clients.
configure nodeid => "myscript/%n/%u";
Example: configure a node using a profile called seed, which is suitable
for a seed node as it binds on all local addresses on a fixed port (4040,
customary for aemp).
# use the aemp commandline utility
# aemp profile seed binds '*:4040'
# then use it
configure profile => "seed";
# or simply use aemp from the shell again:
The original message will be passed to the callback, after the first
element (the tag) has been removed. The callback will use the same
environment as the default callback (see above).
Example: create a port and bind receivers on it in one go.
my $port = rcv port,
msg1 => sub { ... },
msg2 => sub { ... },
;
Example: create a port, bind receivers and send it in a message elsewhere
in one go:
snd $otherport, reply =>
rcv port,
msg1 => sub { ... },
=back
=head1 DISTRIBUTED DATABASE
AnyEvent::MP comes with a simple distributed database. The database will
be mirrored asynchronously on all global nodes. Other nodes bind to one
of the global nodes for their needs. Every node has a "local database"
which contains all the values that are set locally. All local databases
are merged together to form the global database, which can be queried.
The database structure is that of a two-level hash - the database hash
except when you need the lower latency of an already established
connection. To ensure a node establishes a connection to another node,
you can monitor the node port (C<mon $node, ...>), which will attempt to
create the connection (and notify you when the connection fails).
=item Listener-less nodes (nodes without binds) are gone.
And are not coming back, at least not in their old form. If no C<binds>
are specified for a node, AnyEvent::MP assumes a default of C<*:*>.
There are vague plans to implement some form of routing domains, which
might or might not bring back listener-less nodes, but don't count on it.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MPRPC/Server.pm view on Meta::CPAN
Listening port or path to unix socket (Required)
=item address => 'Str'
Bind address. Default to undef: This means server binds all interfaces by default.
If you want to use unix socket, this option should be set to "unix/"
=item on_error => $cb->($handle, $fatal, $message)
view all matches for this distribution
view release on metacpan or search on metacpan
=item allows you to properly pass binary filenames
=item accepts data encoded in any way (does not crash when mpv replies with non UTF-8 data)
=item features a simple keybind/event system
=back
=head2 OVERVIEW OF OPERATION
=item F<--audio-client-name=yourappname>, to make sure audio streams are associated witht eh right program.
=item F<--wid=id>, to embed F<mpv> into another application.
=item F<--no-terminal>, F<--no-input-default-bindings>, F<--no-input-cursor>, F<--input-conf=/dev/null>, F<--input-vo-keyboard=no> - to ensure only you control input.
=back
The return value can be used to decide whether F<mpv> needs initializing:
if ($mpv->start) {
$mpv->bind_key (...);
$mpv->cmd (set => property => value);
...
}
You can immediately starting sending commands when this method returns,
$self->{on_event}($self, $event, $data) if $self->{on_event};
}
=item $mpv->on_key ($string)
Invoked when a key declared by C<< ->bind_key >> is pressed. The default
invokes the C<on_key> code reference specified in the constructor with the
C<$mpv> object and the key name as arguments, or do nothing if none was
given.
For more details and examples, see the C<bind_key> method.
For subclassing, see I<SUBCLASSING>, below.
=cut
sub cmd_recv {
&cmd->recv
}
=item $mpv->bind_key ($INPUT => $string)
This is an extension implement by this module to make it easy to get key
events. The way this is implemented is to bind a C<client-message> witha
first argument of C<AnyEvent::MPV> and the C<$string> you passed. This
C<$string> is then passed to the C<on_key> handle when the key is
proessed, e.g.:
my $mpv = AnyEvent::MPV->new (
print "user pressed escape\n";
}
},
);
$mpv_>bind_key (ESC => "letmeout");
You cna find a list of key names L<in the mpv
documentation|https://mpv.io/manual/stable/#key-names>.
The key configuration is lost when F<mpv> is stopped and must be (re-)done
after every C<start>.
=cut
sub bind_key {
my ($self, $key, $event) = @_;
$event =~ s/([^A-Za-z0-9\-_])/sprintf "\\x%02x", ord $1/ge;
$self->cmd (keybind => $key => "no-osd script-message AnyEvent::MPV key $event");
}
=item [$guard] = $mpv->register_event ($event => $coderef->($mpv, $event, $data))
This method registers a callback to be invoked for a specific
# prevent xscreensaver from doing something stupid, such as starting dbus
$ENV{DBUS_SESSION_BUS_ADDRESS} = "/"; # prevent dbus autostart for sure
$ENV{XDG_CURRENT_DESKTOP} = "generic";
It does bind a number of keys to internal (to doomfrontend) commands:
for (
List::Util::pairs qw(
ESC return
q return
LEFT left
),
(map { ("KP$_" => "num$_") } 0..9),
KP_INS => 0, # KP0, but different
) {
$mpv->bind_key ($_->[0] => $_->[1]);
}
It also reacts to sponsorblock chapters, so it needs to know when vidoe
chapters change. Preadting C<AnyEvent::MPV>, it handles observers
manually:
local $ENV{LC_ALL} = "POSIX";
$self->{mpv}->start (
"--no-terminal",
"--no-input-terminal",
"--no-input-default-bindings",
"--no-input-cursor",
"--input-conf=/dev/null",
"--input-vo-keyboard=no",
"--loop-file=inf",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MySQL.pm view on Meta::CPAN
my $fth = $end3->recv;
my $end4 = AE::cv;
$fth->bind_col(2, \my $a, sub {
warn $_[0];
});
my $fetch; $fetch = sub {
$fth->fetch(sub {
if( $_[0] ) {
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$end4->send;
}
});
}; $fetch->();
#$fth->bind_columns(\my($a, $b), sub {
# warn $_[0];
# warn $AnyEvent::MySQL::errstr;
#});
#my $fetch; $fetch = sub {
# $fth->fetch(sub {
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$_[0]{mysql_insertid};
}
sub _do {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($rev_dir, $dbh, $statement, $attr, @bind_values) = @_;
if( $dbh->{_}[ATTRi]{ReadOnly} && $statement !~ /^\s*(?:show|select|set\s+names)\s+/i ){
_report_error($dbh, 'do', 1227, 'unable to perform write queries on a ReadOnly handle');
$cb->();
return;
}
my @args = ($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->($_[1]);
lib/AnyEvent/MySQL.pm view on Meta::CPAN
else {
_push_task(@args);
}
}
=head2 $dbh->do($statement, [\%attr, [@bind_values,]] [$cb->($rv)])
=cut
sub do {
unshift @_, 0;
&_do;
}
=head2 $dbh->pre_do($statement, [\%attr, [@bind_values,]] [$cb->($rv)])
This method is like $dbh->do except that $dbh->pre_do will unshift
job into the queue instead of push.
This method is for the initializing actions in the AnyEvent::MySQL->connect's callback
lib/AnyEvent/MySQL.pm view on Meta::CPAN
sub pre_do {
unshift @_, 1;
&_do;
}
=head2 $dbh->selectall_arrayref($statement, [\%attr, [@bind_values,]] $cb->($ary_ref))
=cut
sub selectall_arrayref {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($dbh, $statement, $attr, @bind_values) = @_;
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->([]);
lib/AnyEvent/MySQL.pm view on Meta::CPAN
});
}, $cb, 0]);
}
=head2 $dbh->selectall_hashref($statement, [$key_field|\@key_field], [\%attr, [@bind_values,]] $cb->($hash_ref))
=cut
sub selectall_hashref {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
lib/AnyEvent/MySQL.pm view on Meta::CPAN
}
else {
@key_field = ();
}
my($attr, @bind_values) = @_;
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
if( @key_field ) {
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$next_act->();
});
}, $cb, 0]);
}
=head2 $dbh->selectcol_arrayref($statement, [\%attr, [@bind_values,]] $cb->($ary_ref))
=cut
sub selectcol_arrayref {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($dbh, $statement, $attr, @bind_values) = @_;
$attr ||= {};
my @columns = map { $_-1 } @{ $attr->{Columns} || [1] };
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->([]);
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$next_act->();
});
}, $cb, 0]);
}
=head2 $dbh->selectrow_array($statement, [\%attr, [@bind_values,]], $cb->(@row_ary))
=cut
sub selectrow_array {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($dbh, $statement, $attr, @bind_values) = @_;
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->();
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$next_act->();
});
}, $cb, 0]);
}
=head2 $dbh->selectrow_arrayref($statement, [\%attr, [@bind_values,]], $cb->($ary_ref))
=cut
sub selectrow_arrayref {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($dbh, $statement, $attr, @bind_values) = @_;
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->(undef);
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$next_act->();
});
}, $cb, 0]);
}
=head2 $dbh->selectrow_hashref($statement, [\%attr, [@bind_values,]], $cb->($hash_ref))
=cut
sub selectrow_hashref {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my($dbh, $statement, $attr, @bind_values) = @_;
_push_task($dbh, [TXN_TASK, sub {
my $next_act = shift;
AnyEvent::MySQL::Imp::send_packet($dbh->{_}[HDi], 0, AnyEvent::MySQL::Imp::COM_QUERY, _text_prepare($statement, @bind_values));
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[HDi], sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$dbh->{mysql_insertid} = $_[2];
$cb->(undef);
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$sth->[STATEMENTi] = $statement;
return $sth;
}
=head2 $sth->execute(@bind_values, [\%attr,] [$cb->($fth/$rv)])
=cut
sub execute {
my $cb = ref($_[-1]) eq 'CODE' ? pop : \&AnyEvent::MySQL::_empty_cb;
my $attr = ref($_[-1]) eq 'HASH' ? pop : {};
my($sth, @bind_values) = @_;
my $dbh = $sth->[DBHi];
AnyEvent::MySQL::db::_push_task($dbh, [AnyEvent::MySQL::db::TXN_TASK, sub {
my $next_act = shift;
my $execute = sub {
AnyEvent::MySQL::Imp::do_execute_param($dbh->{_}[AnyEvent::MySQL::db::HDi], $sth->[IDi], \@bind_values, $sth->[PARAMi]);
AnyEvent::MySQL::Imp::recv_response($dbh->{_}[AnyEvent::MySQL::db::HDi], execute => 1, sub {
eval {
if( $_[0]==AnyEvent::MySQL::Imp::RES_OK ) {
$cb->($_[1]);
}
lib/AnyEvent/MySQL.pm view on Meta::CPAN
$fth->[DATAi] = $data_set;
return $fth;
}
=head2 $rc = $fth->bind_columns(@list_of_refs_to_vars_to_bind, [$cb->($rc)])
=cut
sub bind_columns {
my $cb = ref($_[-1]) eq 'CODE' ? pop : undef;
my $fth = shift;
my @list_of_refs_to_vars_to_bind = @_;
if( !@{$fth->[DATAi]} ) {
$cb->(1) if $cb;
return 1;
}
elsif( @{$fth->[DATAi][0]} == @list_of_refs_to_vars_to_bind ) {
$fth->[BINDi] = \@list_of_refs_to_vars_to_bind;
$cb->(1) if $cb;
return 1;
}
else {
$cb->() if $cb;
return;
}
}
=head2 $rc = $fth->bind_col($col_num, \$col_variable, [$cb->($rc)])
=cut
sub bind_col {
my $cb = ref($_[-1]) eq 'CODE' ? pop : undef;
my($fth, $col_num, $col_ref) = @_;
if( !@{$fth->[DATAi]} ) {
$cb->(1) if $cb;
lib/AnyEvent/MySQL.pm view on Meta::CPAN
sub fetch {
my $cb = ref($_[-1]) eq 'CODE' ? pop : undef;
my $fth = shift;
if( $fth->[BINDi] && $fth->[DATAi] && @{$fth->[DATAi]} ) {
my $bind = $fth->[BINDi];
my $row = shift @{$fth->[DATAi]};
for(my $i=0; $i<@$row; ++$i) {
${$bind->[$i]} = $row->[$i] if $bind->[$i];
}
$cb->(1) if $cb;
return 1;
}
else {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Net/Amazon/S3.pm view on Meta::CPAN
$conf ||= {};
my $bucket = $conf->{bucket};
croak 'must specify bucket' unless $bucket;
my $cv = AE::cv;
Module::AnyEvent::Helper::bind_scalar($cv, $self->list_bucket_async($conf), sub {
my $response = shift->recv;
return $response unless $response->{is_truncated};
my $all = $response;
my $iter; $iter = sub {
my $next_marker = $response->{next_marker}
|| $response->{keys}->[-1]->{key};
$conf->{marker} = $next_marker;
$conf->{bucket} = $bucket;
Module::AnyEvent::Helper::bind_scalar($cv, $self->list_bucket_async($conf), sub {
$response = shift->recv;
push @{ $all->{keys} }, @{ $response->{keys} };
if($response->{is_truncated}) {
$iter->();
} else {
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Test/HTTP/AnyEvent/Server.pm view on Meta::CPAN
=head1 ATTRIBUTES
=head2 address
Address to bind the server.
Defaults to C<127.0.0.1>.
=head2 port
Port to bind the server.
Picks the first available by default.
=head2 maxconn
Limit the number of accepted connections to this.
view all matches for this distribution
view release on metacpan or search on metacpan
t/03-discover.t view on Meta::CPAN
use IO::Socket::INET;
socket my $s, PF_INET, SOCK_DGRAM, getprotobyname('udp');
setsockopt $s, SOL_SOCKET, SO_BROADCAST, 1;
binmode $s;
bind $s, sockaddr_in(0, inet_aton('127.0.0.1'))
or plan skip_all => "Failed to bind to loopback address: $!";
my ($port, $addr) = sockaddr_in(getsockname($s));
my $tcp =
IO::Socket::INET->new(Listen => 5, Proto => 'tcp',
LocalAddr => '127.0.0.1', LocalPort => 0)
or plan skip_all => "Failed to listen on loopback address: $!";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/PgRecvlogical.pm view on Meta::CPAN
$recv->start;
=head1 DESCRIPTION
C<AnyEvent::PgRecvlogical> provides perl bindings of similar functionality to that of
L<pg_recvlogical|https://www.postgresql.org/docs/current/static/app-pgrecvlogical.html>.
The reasoning being that C<pg_recvlogical> does afford the consuming process the opportunity to emit feedback to
PostgreSQL. This results is potentially being sent more data than you can handle in a timely fashion.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Ping.pm view on Meta::CPAN
=head3 C<timeout>
=head3 C<on_prepare>
In some cases you need to "tune" the socket before it is used to ping (for
exmaple, to bind it on a given IP address).
my $ping = AnyEvent::Ping->new(
on_prepare => sub {
my $socket = shift;
...
view all matches for this distribution