view release on metacpan or search on metacpan
lib/DBIx/RetryOverDisconnects.pm view on Meta::CPAN
=head2 set_callback
$dbh->set_callback(afterReconnect => $code_ref);
Set callbacks for some events. Currently only afterReconnect is supported.
It is called after every successful reconnect to database.
=cut
sub set_callback {
my ($self, %callbacks) = @_;
my $old = $self->{PRIV()}->{callback} || {};
$self->{PRIV()}->{callback} = {%$old, %callbacks};
return;
}
sub exc_conn_trans {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
C<DBIx::Roles::Default> - not a module on its own, but a package that is
always imported, and need not to be imported explicitly. Implements actual calls
to DBI handle.
L<DBIx::Roles::Hook> - Exports callbacks to override DBI calls.
L<DBIx::Roles::InlineArray> - Flattens arrays passed as parameters to DBI calls into strings.
L<DBIx::Roles::RaiseError> - Change defaults to C<< RaiseError => 1 >>
view all matches for this distribution
view release on metacpan or search on metacpan
SQLEngine/Record/Hooks.pm view on Meta::CPAN
package My::Record;
use DBIx::SQLEngine::Record::Class '-isasubclass', 'Hooks';
My::Record->table( $sqldb->table($table_name) );
B<Hooks:> Register subs for callbacks.
DBIx::SQLEngine::Record::Hooks->install_hooks(
post_new => sub { warn "Record $_[0] created" },
post_fetch => sub { warn "Record $_[0] loaded" },
post_insert => sub { warn "Record $_[0] inserted" },
SQLEngine/Record/Hooks.pm view on Meta::CPAN
########################################################################
=head1 HOOKS INTERFACE
Many of the methods below are labeled "Inheritable Hook." These methods allow you to register callbacks which are then invoked at specific points in each record's lifecycle. You can add these callbacks to all record classes, to a particular class, or...
These hooks act like the triggers supported by some databases; you can ensure that every time a record is updated in a specific table, certain other actions occur automatically.
To register a callback, call the install_hooks method, and pass it pairs of a hook method name, and a subroutine reference, as follows: I<callee>->install_hooks( I<methodname> => I<coderef>, ... ).
SQLEngine/Record/Hooks.pm view on Meta::CPAN
=item install_hooks()
$classname->install_hooks( $hook_name => \&my_sub, ... )
$record->install_hooks( $hook_name => \&my_sub, ... )
Registers one or more callbacks. Accepts pairs of a hook method name, and a subroutine reference.
For more about the implementation of the Hook mechanism, see L<Class::MakeMethods::Composite::Inheritable>.
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Squirrel/it.pm view on Meta::CPAN
);
use Sub::Name 'subname';
use DBIx::Squirrel::util qw(
cluckf
confessf
callbacks_args
);
use namespace::clean;
use constant E_BAD_STH => 'Expected a statement handle object';
use constant E_BAD_SLICE => 'Slice must be a reference to an ARRAY or HASH';
lib/DBIx/Squirrel/it.pm view on Meta::CPAN
=cut
sub new {
my $class = ref $_[0] ? ref shift : shift;
my( $transforms, $sth, @bind_values ) = callbacks_args(@_);
confessf E_BAD_STH unless UNIVERSAL::isa( $sth, 'DBIx::Squirrel::st' );
my $self = bless {}, $class;
$self->_private_state( {
sth => $sth,
bind_values_initial => [@bind_values],
lib/DBIx/Squirrel/it.pm view on Meta::CPAN
*slice_buffer_size = subname( slice_buffer_size => \&slice_cache_size );
}
sub start {
my( $attr, $self ) = shift->_private_state;
my( $transforms, @bind_values ) = callbacks_args(@_);
if ( @{$transforms} ) {
$attr->{transforms} = [ @{ $attr->{transforms_initial} }, @{$transforms} ];
}
else {
unless ( defined $attr->{transforms} && @{ $attr->{transforms} } ) {
view all matches for this distribution
view release on metacpan or search on metacpan
Changelog.ini view on Meta::CPAN
- Fix t/*.t and examples/*.pl to use DBI_DSN, DBI_USER and DBI_PASS
from the environment, if defined, or to default to SQLite.
MySQL is no longer hard-coded anywhere.
- Fix bug where when the constructor call includes both match_data and
start_id, and the id of the match_data is not start_id, then the _do_query()
method would fail to find a record, which meant both the callbacks passed in
to the constructor (method and post_method), if defined, would be called with
an undefined value for $param{item}. This meant the callbacks would be called
one more time that they should have been. This faulty call took place before
any valid call took place.
EOT
[V 1.9]
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/TxnPool.pm view on Meta::CPAN
server does fsync (data flushing to disk) after each statement. It can be very
slow for many updates. The best solution can be to wrap some
insert/delete/update statements in one transaction for example. But this raises
a new problem - deadlocks. If a deadlock occurs a DBI module throws exceptions
and ideal way to repeat SQL statements again. This module helps to make it. It
has a pool inside for data (FIFO buffer) and calls your callbacks for each
pushed item. When your pool to be fed by your data, it wraps data in one
transaction up to the maximum defined size or up to the finish method. If
deadlock occurs a pool repeats your callbacks for every item again. You can
define a second callback which will be executed for every item after wrapped
transaction. For example there can be non-SQL statements, for example a deleting
files, cleanups and etc.
=head1 CONSTRUCTOR
view all matches for this distribution
view release on metacpan or search on metacpan
* documented reconnect() method
* update() and smartUpdate() will now ignore (just return a
true value) when called with empty $data
Version 0.15
* Documented callbacks
Version 0.14
* The data_source argument to connect() can now be a hash
* Unknown method calls will be passed to the underlying DBI
object. So now you can make calls like prepare() which
view all matches for this distribution
view release on metacpan or search on metacpan
glueHTML.pm view on Meta::CPAN
=over 4
=item Future Additions
In a later version, callbacks to add user defined form parameters to
allow state keeping such as password protection etc.
=item B<set_printheader> B<(>I<Callback function address>B<,> I<Print content type header (1/0)>B<);>
sub printheader {
view all matches for this distribution
view release on metacpan or search on metacpan
* Added support to allow DB_File to build with Berkeley DB 4.1.X
* Tightened up the test harness to test that calls to untie don't generate
the "untie attempted while %d inner references still exist" warning.
* added code to guard against calling the callbacks (compare,hash & prefix)
recursively.
* passing undef for the flags and/or mode when opening a database could cause
a "Use of uninitialized value in subroutine entry" warning. Now silenced.
1.0
DB_File has been in use for over a year. To reflect that, the
version number has been incremented to 1.0.
Added complete support for multiple concurrent callbacks.
Using the push method on an empty list didn't work properly. This
has been fixed.
0.3
Added prototype support for multiple btree compare callbacks.
0.2
When DB_File is opening a database file it no longer terminates the
process if dbopen returned an error. This allows file protection
view all matches for this distribution
view release on metacpan or search on metacpan
ddc-tee.perl view on Meta::CPAN
close($fh)
or die("$prog: close failed for $pidfile: $!");
}
##======================================================================
## callbacks
## undef = cb_client($cli_sock)
sub cb_client {
my $csock = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DDG/Test/Spice.pm view on Meta::CPAN
alt_to_test('DDG::Spice::My::Spice', [qw(alt1 alt2 alt3)]);
This would check for the following:
callbacks 'ddg_spice_my_alt[123]'
paths '/js/spice/my/alt[123]/'
=head1 AUTHOR
DuckDuckGo <open@duckduckgo.com>
view all matches for this distribution
view release on metacpan or search on metacpan
demo/lib/DJabberd/Plugin/Demo.pm view on Meta::CPAN
### initialize a logger
our $logger = DJabberd::Log->get_logger();
### register our plugin. we don't need to do any actions now, but we're
### registering two hooks to be called on certain events. Hooks are implemented
### using callbacks. To see which hooks are available, read 'DJabberd::HookDocs'.
### To see how callbacks work, see 'DJabberd::Callback'.
sub register {
my($self, $vhost) = @_;
### when the client asks for the roster, call this hook first. This allows
### us to manipulate the roster before the client sees it.
demo/lib/DJabberd/Plugin/Demo.pm view on Meta::CPAN
### Update the roster to add the bot (as described in $ritem) to the
### client (as described in $jid). Will call callback $rs_cb when done.
$rs->addupdate_roster_item( $rs_cb, $jid, $ritem );
### callbacks have the possiblity to stop the callback chain from
### continuing, by either throwing an error or telling the callback
### mechanism it is done. In our case, we want the chain to continue.
### See DJabberd::HookDocs for details on this.
$cb->decline;
}
view all matches for this distribution
view release on metacpan or search on metacpan
jbuf_puts(j, "\"\n", 2);
jbuf_indent(j, indent);
jbuf_putc(j, '}');
}
/* write_value callbacks â write the inner string of a tagged scalar
* (no surrounding quotes; the caller already wrote them). */
static void wv_bool(jbuf *j, const dms_value *v) {
jbuf_putcstr(j, v->u.b ? "true" : "false");
}
view all matches for this distribution
view release on metacpan or search on metacpan
jbuf_puts(j, "\"\n", 2);
jbuf_indent(j, indent);
jbuf_putc(j, '}');
}
/* write_value callbacks â write the inner string of a tagged scalar
* (no surrounding quotes; the caller already wrote them). */
static void wv_bool(jbuf *j, const dms_value *v) {
jbuf_putcstr(j, v->u.b ? "true" : "false");
}
view all matches for this distribution
view release on metacpan or search on metacpan
sundown/examples/sundown.c view on Meta::CPAN
{
struct buf *ib, *ob;
int ret;
FILE *in = stdin;
struct sd_callbacks callbacks;
struct html_renderopt options;
struct sd_markdown *markdown;
/* opening the file if given from the command line */
if (argc > 1) {
sundown/examples/sundown.c view on Meta::CPAN
fclose(in);
/* performing markdown parsing */
ob = bufnew(OUTPUT_UNIT);
sdhtml_renderer(&callbacks, &options, 0);
markdown = sd_markdown_new(0, 16, &callbacks, &options);
sd_markdown_render(ob, ib->data, ib->size, markdown);
sd_markdown_free(markdown);
/* writing the result to stdout */
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DR/Tarantool/AsyncClient.pm view on Meta::CPAN
}
=head1 Worker methods
All methods accept callbacks which are invoked with the following arguments:
=over
=item status
view all matches for this distribution
view release on metacpan or search on metacpan
CAB/Queue/Server.pm view on Meta::CPAN
## $cli_or_undef = $qs->accept($timeout_secs)
## + accept incoming client connections with optional timeout
## + INHERITED from DTA::CAB::Socket
## $rc = $qs->handleClient($cli)
## $rc = $qs->handleClient($cli, %callbacks)
## + handle a single client request
## + INHERITED from DTA::CAB::Socket
##--------------------------------------------------------------
## Server Methods: Request Handling
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daemon/Shutdown.pm view on Meta::CPAN
# Validate the config file
%params = validate_with(
params => \%params,
spec => {
config => {
callbacks => {
'File exists' => sub { -f shift }
},
default => '/etc/sdd.conf',
},
},
lib/Daemon/Shutdown.pm view on Meta::CPAN
%params = validate_with(
params => \%params,
spec => {
log_file => {
default => '/var/log/sdd.log',
callbacks => {
'Log file is writable' => sub {
my $filepath = shift;
if ( -f $filepath ) {
return -w $filepath;
} else {
lib/Daemon/Shutdown.pm view on Meta::CPAN
regex => qr/^[1|0]$/,
},
shutdown_binary => {
default => '/sbin/poweroff',
type => SCALAR,
callbacks => {
'Shutdown binary exists' => sub {
-x shift();
},
},
},
view all matches for this distribution
view release on metacpan or search on metacpan
- Documentation improvements. (debug-ito++)
- use Exporter in Daiku.pm instead of manually writing import(). (debug-ito++)
1.001 2014-05-11T12:39:01Z
- pass argv to merged task callbacks
(Shoichi Kaji)
- support multiple suffix rule
(Shoichi Kaji)
- support coredef src in suffix rule
(Songmu)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Daizu/Util.pm view on Meta::CPAN
my $parser = XML::LibXML->new;
$parser->expand_xinclude(1);
my @included_file;
my $input_callbacks = XML::LibXML::InputCallback->new;
$input_callbacks->register_callbacks([
\&_match_uri,
sub { _open_uri($db, $wc_id, \@included_file, @_) },
\&_read_uri,
\&_close_uri,
]);
$parser->input_callbacks($input_callbacks);
my $root = $doc->documentElement;
$root->setAttribute('xml:base' => 'daizu:///' . url_encode($path))
unless $root->hasAttribute('xml:base');
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/Async.pm view on Meta::CPAN
EV::loop
=head1 PROBLEMS
In the callbacks (for example of the timer in the C<SYNOPSIS>), you cannot use
many of the normal Dancer keywords such as template, redirect, etc. This is due
to Dancer accessing Dancer::SharedData, which is not available later on. If
anyone has a good idea on how to solve this problem, suggestions/patches are
very welcome.
view all matches for this distribution
view release on metacpan or search on metacpan
0.99_10 2016-02-06T09:36:21+01:00 (77f07bf => abeltje)
- (abeltje, Sat, 6 Feb 2016 09:36:21 +0100) Autocommit for distribution
Dancer::Plugin::RPC 0.99_10 (test)
- (Larion Garaczi, Tue, 22 Mar 2016 13:58:55 +0100) Handle unhandled
exceptions in callbacks
- Runtime exceptions in the 'callback' functions were not caught. Now
we
- handle them the same way as runtime exceptions in the actual
methods.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/SimpleCRUD.pm view on Meta::CPAN
##Return results as a downloaded file, instead of generating the HTML table.
return _return_downloadable_query($args, $sth, params->{format});
}
my @custom_callbacks = ();
for my $custom_col_spec (@{ $args->{custom_columns} || [] } ) {
push @custom_callbacks, {
column=>$custom_col_spec->{name},
transform=> ($custom_col_spec->{transform} or sub { return shift;}),
};
}
my $table = HTML::Table::FromDatabase->new(
-sth => $sth,
-border => 1,
-callbacks => [
{
column => 'actions',
transform => sub {
my $id = shift;
my $action_links;
lib/Dancer/Plugin/SimpleCRUD.pm view on Meta::CPAN
}
}
return $action_links;
},
},
@custom_callbacks,
],
-rename_headers => \%columns_sort_options,
-html => 'escape',
-class => $table_class,
);
view all matches for this distribution
view release on metacpan or search on metacpan
carton.lock view on Meta::CPAN
"version" : "1.1902"
},
"B::Hooks::OP::Check" : {
"dist" : "B-Hooks-OP-Check-0.19",
"mymeta" : {
"abstract" : "Wrap OP check callbacks",
"author" : [
"Florian Ragwitz <rafl@debian.org>"
],
"dynamic_config" : 0,
"generated_by" : "Module::Install version 1.01, CPAN::Meta::Converter version 2.120921",
view all matches for this distribution
view release on metacpan or search on metacpan
public/javascripts/typeahead/typeahead-0.11.1.bundle.js view on Meta::CPAN
if (!cb) {
return this;
}
types = types.split(splitter);
cb = context ? bindContext(cb, context) : cb;
this._callbacks = this._callbacks || {};
while (type = types.shift()) {
this._callbacks[type] = this._callbacks[type] || {
sync: [],
async: []
};
this._callbacks[type][method].push(cb);
}
return this;
}
function onAsync(types, cb, context) {
return on.call(this, "async", types, cb, context);
public/javascripts/typeahead/typeahead-0.11.1.bundle.js view on Meta::CPAN
function onSync(types, cb, context) {
return on.call(this, "sync", types, cb, context);
}
function off(types) {
var type;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
while (type = types.shift()) {
delete this._callbacks[type];
}
return this;
}
function trigger(types) {
var type, callbacks, args, syncFlush, asyncFlush;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
args = [].slice.call(arguments, 1);
while ((type = types.shift()) && (callbacks = this._callbacks[type])) {
syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args));
asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args));
syncFlush() && nextTick(asyncFlush);
}
return this;
}
function getFlush(callbacks, context, args) {
return flush;
function flush() {
var cancelled;
for (var i = 0, len = callbacks.length; !cancelled && i < len; i += 1) {
cancelled = callbacks[i].apply(context, args) === false;
}
return !cancelled;
}
}
function getNextTick() {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer.pm view on Meta::CPAN
if ( $options{'streaming'} ) {
# handle streaming
$resp->streamed( sub {
my ( $status, $headers ) = @_;
my %callbacks = defined $options{'callbacks'} ?
%{ $options{'callbacks'} } :
();
return sub {
my $respond = shift;
exists $callbacks{'override'}
and return $callbacks{'override'}->( $respond, $resp );
# get respond callback and set headers, get writer in return
my $writer = $respond->( [
$status,
$headers,
] );
# get content from original response
my $content = $resp->content;
exists $callbacks{'around'}
and return $callbacks{'around'}->( $writer, $content );
if ( ref $content ) {
my $bytes = $options{'bytes'} || '43008'; # 42K (dams)
my $buf;
while ( ( my $read = sysread $content, $buf, $bytes ) != 0 ) {
if ( exists $callbacks{'around_content'} ) {
$callbacks{'around_content'}->( $writer, $buf );
} else {
$writer->write($buf);
}
}
} else {
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file( params->{file}, streaming => 1 );
}
You can control what happens using callbacks.
First, C<around_content> allows you to get the writer object and the chunk of
content read, and then decide what to do with each chunk:
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
around_content => sub {
my ( $writer, $chunk ) = @_;
$writer->write("* $chunk");
},
},
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
around => sub {
my ( $writer, $content ) = @_;
# we know it's a text file, so we'll just stream
# line by line
lib/Dancer.pm view on Meta::CPAN
get '/download/:file' => sub {
send_file(
params->{file},
streaming => 1,
callbacks => {
override => sub {
my ( $respond, $response ) = @_;
my $writer = $respond->( [ $newstatus, $newheaders ] );
$writer->write("some line");
view all matches for this distribution
view release on metacpan or search on metacpan
[BUG FIXES]
* Incorrect call to user_password from app not plugin
(Andrew Beverly, GH #53).
* Avoid memory leaks in BUILD by passing weakened ref to plugin into
add_route callbacks (Peter Mottram).
* Call $app->session instead of $app->app->session in _post_login_route
(Peter Mottram).
[MISC]
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/JobScheduler/Client/TheSchwartz.pm view on Meta::CPAN
if ( $self->config->{'databases'} ) {
my $databases = $self->config->{'databases'};
foreach my $key ( keys %{$databases} ) {
my $database = $databases->{$key};
if ( $database->{'dbh_callback'} ) {
my $e = q{Invalid config. } . q{databases->%s has item dbh_callback; database specific callbacks not supported};
$log->errorf( $e, $key );
croak sprintf $e, $key;
}
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/70dancer2.t view on Meta::CPAN
encoder_args => {
croak_on_bless => 0,
# Messages from later versions of Log::Report do not
# serialize cleanly. Therefore use the object's freeze and
# thaw methods.
freeze_callbacks => 1,
},
decoder_args => {
refuse_objects => 0,
},
},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Multilang.pm view on Meta::CPAN
The default language that will be used when plugin can't guess desired one (or when desired one is not managed)
=item C<no_lang_prefix> (optional)
Do not add the language path to the route if it has this prefix. Useful for Google or Facebook authentication callbacks.
no_lang_prefix: /auth
=back
view all matches for this distribution