Result:
found more than 837 distributions - search limited to the first 2001 files matching your query ( run in 0.457 )


AnyEvent-FIFO

 view release on metacpan or  search on metacpan

lib/AnyEvent/FIFO.pm  view on Meta::CPAN

90
91
92
93
94
95
96
97
98
99
AnyEvent::FIFO - Simple FIFO Callback Dispatch
 
=head1 SYNOPSIS
 
    my $fifo = AnyEvent::FIFO->new(
        max_active => 1, # max "concurrent" callbacks to execute per slot
    );
 
    # send to the "default" slot
    $fifo->push( \&callback, @args );

lib/AnyEvent/FIFO.pm  view on Meta::CPAN

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
=head1 DESCRIPTION
 
AnyEvent::FIFO is a simple FIFO queue to dispatch events in order.
 
If you use regular watchers and register callbacks from various places in
your program, you're not necessarily guaranteed that the callbacks will be
executed in the order that you expect. By using this module, you can
register callbacks and they will be executed in that particular order.
 
=head1 METHODS
 
=head2 new
 
=over 4
 
=item max_active => $number
 
Number of concurrent callbacks to be executed B<per slot>.
 
=item cv => $cv
 
Instance of L<AnyEvent condvar|AnyEvent/"CONDITION VARIABLES">. AnyEvent::FIFO will create one for you if this is not provided.

 view all matches for this distribution


AnyEvent-FTP

 view release on metacpan or  search on metacpan

lib/AnyEvent/FTP/Role/Event.pm  view on Meta::CPAN

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
=head1 DESCRIPTION
 
This role provides a uniform even callback mechanism for classes in L<AnyEvent::FTP>.
You declare events by using the C<define_events> method.  Once declared
you can use C<on_>I<event_name> to add a callback to a particular event
and C<emit> to trigger those callbacks.
 
=head1 METHODS
 
=head2 define_events
 
 __PACKAGE__->define_events( @list_of_event_names );
 
This is called within the class package to declare the event names for all
events used by the class.  It creates methods of the form C<on_>I<event_name>
which can be used to add callbacks to events.
 
=head2 emit
 
 $obj->emit($event_name, @arguments);
 
This calls the callbacks associated with the given C<$event_name>.
It will pass to that callback the given C<@arguments>.
 
=head1 SEE ALSO
 
=over 4

 view all matches for this distribution


AnyEvent-FastPing

 view release on metacpan or  search on metacpan

FastPing.pm  view on Meta::CPAN

81
82
83
84
85
86
87
88
89
90
91
=head1 THE AnyEvent::FastPing CLASS
 
The AnyEvent::FastPing class represents a single "pinger". A "pinger"
comes with its own thread to send packets in the background, a rate-limit
machinery and separate idle/receive callbacks.
 
The recommended workflow (there are others) is this: 1. create a new
AnyEvent::FastPing object 2. configure the address lists and ranges to
ping, also configure an idle callback and optionally a receive callback
3. C<start> the pinger.

 view all matches for this distribution


AnyEvent-Finger

 view release on metacpan or  search on metacpan

lib/AnyEvent/Finger.pm  view on Meta::CPAN

119
120
121
122
123
124
125
126
127
128
=head2 finger_server
 
 my $server = finger_server $callback, \%options;
 
Start listening to finger callbacks and call the given callback
for each request.  See L<AnyEvent::Finger::Server> for details
on the options and the callback.
 
=head1 CAVEATS

 view all matches for this distribution


AnyEvent-Fork-Pool

 view release on metacpan or  search on metacpan

Pool.pm  view on Meta::CPAN

598
599
600
601
602
603
604
605
606
607
608
=back
 
=head1 EXCEPTIONS
 
The same "policy" as with L<AnyEvent::Fork::RPC> applies - exceptions
will not be caught, and exceptions in both worker and in callbacks causes
undesirable or undefined behaviour.
 
=head1 SEE ALSO
 
L<AnyEvent::Fork>, to create the processes in the first place.

 view all matches for this distribution


AnyEvent-Fork-RPC

 view release on metacpan or  search on metacpan

RPC.pm  view on Meta::CPAN

847
848
849
850
851
852
853
854
855
856
857
to send an error message just before exiting, or when you want to ensure
replies timely reach the parent before starting a long blocking operation.
 
In these cases, you can call this function to flush any outstanding reply
data to the parent. This is done blockingly, so no requests will be
handled and no event callbacks will be called.
 
For example, you could wrap your request function in a C<eval> block and
report the exception string back to the caller just before exiting:
 
   sub req {

 view all matches for this distribution


AnyEvent-ForkObject

 view release on metacpan or  search on metacpan

t/01_fo.t  view on Meta::CPAN

147
148
149
150
151
152
153
154
155
156
157
    my $timeout; $timeout = AE::timer 1, 0 => sub { undef $timeout; $cv->send };
 
    $cv->recv;
 
    ok $dont_call_if_destroyed, "Don't touch callbacks if destroyed";
    ok $timeout, "Timeout wasn't reached";
}
 
 
package FO_Test;

 view all matches for this distribution


AnyEvent-GDB

 view release on metacpan or  search on metacpan

GDB.pm  view on Meta::CPAN

16
17
18
19
20
21
22
23
24
25
26
It properly quotes your commands and parses the data structures returned
by GDB.
 
At the moment, it's in an early stage of development, so expect changes,
and, over time, further features (such as breakpoint-specific callbacks
and so on).
 
=head1 EXAMPLE PROGRAM
 
To get you started, here is an example program that runs F</bin/ls>,

GDB.pm  view on Meta::CPAN

495
496
497
498
499
500
501
502
503
504
Like C<cmd>, but blocks execution until the command has been executed, and
returns the results if sucessful. Croaks when GDB returns with an error.
 
This is purely a convenience method for small scripts: since it blocks
execution using a condvar, it is not suitable to be used inside callbacks
or modules.
 
That is, unless L<Coro> is used - with Coro, you can run multiple
C<cmd_sync> methods concurrently form multiple threads, with no issues.

GDB.pm  view on Meta::CPAN

677
678
679
680
681
682
683
684
685
686
687
Any callback specified as C<on_EVENTNAME> parameter to the constructor.
 
=back
 
You can change callbacks dynamically by simply replacing the corresponding
C<on_XXX> member in the C<$gdb> object:
 
   $gdb->{on_event} = sub {
      # new event handler
   };

 view all matches for this distribution


AnyEvent-GPSD

 view release on metacpan or  search on metacpan

GPSD.pm  view on Meta::CPAN

45
46
47
48
49
50
51
52
53
54
argument is missing then C<localhost:2947> will be used.
 
If the connection cannot be established, then it will retry every
second. Otherwise, the connection is put into watcher mode.
 
You can specify various configuration parameters, most of them callbacks:
 
=over 4
 
=item host => $hostname

 view all matches for this distribution


AnyEvent-Gearman

 view release on metacpan or  search on metacpan

lib/AnyEvent/Gearman/Client.pm  view on Meta::CPAN

141
142
143
144
145
146
147
148
149
150
151
152
153
The namespace is currently implemented as a simple tab separated concatenation of the prefix and the function name.
 
=back
 
=head2 add_task($function, $workload, %callbacks)
 
Start new job and wait results in C<%callbacks>
 
    $gearman->add_task(
        $function => $workload,
        on_complete => sub {
            my $result = $_[1],

lib/AnyEvent/Gearman/Client.pm  view on Meta::CPAN

157
158
159
160
161
162
163
164
165
166
        },
    );
 
C<$function> is a worker function name, and C<$workload> is a data that will be passed to worker.
 
C<%callbacks> is set of callbacks called by job events. Available callbacks are:
 
=over 4
 
=item on_complete => $cb->($self, $result)

lib/AnyEvent/Gearman/Client.pm  view on Meta::CPAN

191
192
193
194
195
196
197
198
199
200
201
202
203
204
=back
 
You should to set C<on_complete> and C<on_fail> at least.
 
 
=head2 add_task_bg($function, $workload, %callbacks)
 
Starts a new background job. The parameters are the same as
L<add_task($function, $workload, %callbacks)|add_task()>, but the only
callback that is called is C<on_created>.
 
    $gearman->add_task_bg(
        $function => $workload,
        on_created => sub {

 view all matches for this distribution



AnyEvent-HTTP-LWP-UserAgent

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

5
6
7
8
9
10
11
12
13
14
15
Makefile.PL
README
dist.ini
lib/AnyEvent/HTTP/LWP/UserAgent.pm
t/async.t
t/callbacks.t
t/invalid_host.t
t/main.t
t/release-pod-syntax.t
t/request_content_ref.t
t/response_content_cb.t

 view all matches for this distribution


AnyEvent-HTTP

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

93
94
95
96
97
98
99
100
101
102
        - bump AnyEvent dependency version (reported by Richard Harris).
 
2.1  Thu Feb 24 13:11:51 CET 2011
        - the keepalive and persistent parameters were actually named
          differently in the code - they now work as documented.
        - fix a bug where callbacks would sometimes never be called when
          the request timeout is near or below the persistent connection
          timeout (testcase by Cindy Wang).
        - destroying the guard would have no effect when a request was
          recursing or being retired.

 view all matches for this distribution


AnyEvent-HTTPBenchmark

 view release on metacpan or  search on metacpan

benchmark.pl  view on Meta::CPAN

40
41
42
43
44
45
46
47
48
49
50
#starting requests
for ( 1 .. $concurency ) {
    add_request( $_, $url );
}
 
$cv->recv;      # begin receiving message and make callbacks magic ;)
end_bench();    # call the end
 
#subs
sub parse_command_line {
    if (not defined @ARGV)

 view all matches for this distribution


AnyEvent-HTTPD-ExtDirect

 view release on metacpan or  search on metacpan

lib/AnyEvent/HTTPD/ExtDirect.pm  view on Meta::CPAN

82
83
84
85
86
87
88
89
90
91
sub run {
    my ($self) = @_;
     
    my $config = $self->config;
 
    $self->set_callbacks(
        api_path    => $config->api_path,
        router_path => $config->router_path,
        poll_path   => $config->poll_path,
    );

lib/AnyEvent/HTTPD/ExtDirect.pm  view on Meta::CPAN

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    $self->stop_request;
}
 
### PUBLIC INSTANCE METHOD ###
#
# Register the callbacks for Ext.Direct handlers.
# This effectively "primes" the server but does not make it
# enter a blocking wait.
#
 
sub set_callbacks {
    my ($self, %arg) = @_;
 
    my $config = $self->config;
     
    my $api_path    = $arg{api_path}    || $config->api_path;

 view all matches for this distribution


AnyEvent-HTTPD-Router

 view release on metacpan or  search on metacpan

lib/AnyEvent/HTTPD/Router.pm  view on Meta::CPAN

125
126
127
128
129
130
131
132
133
134
135
136
137
This module aims to add as little as possible overhead to it while still being
flexible and extendable. It requires the same little dependencies that
L<AnyEvent::HTTPD> uses.
 
The dispatching for the routes happens first. If no route could be found, or you
do not stop further dispatching with C<stop_request()> the registered callbacks
will be executed as well; as if you would use L<AnyEvent::HTTPD>. In other
words, if you plan to use routes in your project you can use this module and
upgrade from callbacks to routes step by step.
 
Routes support http methods, but custom methods
don't need to, of course ;-)

lib/AnyEvent/HTTPD/Router.pm  view on Meta::CPAN

239
240
241
242
243
244
245
246
247
248
249
250
251
=item * no_route_found => $request
 
When the dispatcher can not find a route that matches on your request, the
event C<no_route_found> will be emitted.
 
In the case that routes and callbacks (C<reg_cb()>) for paths as used with
C<AnyEvent::HTTPD> are mixed, keep in mind that that C<no_route_found> will
happen before the other path callbacks are executed. So for a
C<404 not found> handler you could do
 
    $httpd->reg_cb('' => sub {
        my ( $httpd, $req ) = @_;
        $req->respond( [ 404, 'not found', {}, '' ] );

 view all matches for this distribution


AnyEvent-HTTPD

 view release on metacpan or  search on metacpan

lib/AnyEvent/HTTPD.pm  view on Meta::CPAN

84
85
86
87
88
89
90
91
92
93
94
The L<AnyEvent::HTTPD> class inherits directly from
L<AnyEvent::HTTPD::HTTPServer> which inherits the event callback interface from
L<Object::Event>.
 
Event callbacks can be registered via the L<Object::Event> API (see the
documentation of L<Object::Event> for details).
 
For a list of available events see below in the I<EVENTS> section.
 
=over 4

lib/AnyEvent/HTTPD.pm  view on Meta::CPAN

162
163
164
165
166
167
168
169
170
171
=item allowed_methods => $arrayref
 
This parameter sets the allowed HTTP methods for requests, defaulting to GET,
HEAD and POST.  Each request received is matched against this list, and a
'501 not implemented' is returned if no match is found.  Requests using
disallowed handlers will never trigger callbacks.
 
=back
 
=cut

 view all matches for this distribution


AnyEvent-Handle-UDP

 view release on metacpan or  search on metacpan

lib/AnyEvent/Handle/UDP.pm  view on Meta::CPAN

393
394
395
396
397
398
399
400
401
402
=head2 wtimeout
 
If non-zero, then these enables an "inactivity" timeout: whenever this many seconds pass without a successful read or write on the underlying file handle (or a call to C<timeout_reset>), the on_timeout callback will be invoked (and if that one is mis...
 
There are three variants of the timeouts that work independently of each other, for both read and write (triggered when nothing was read OR written), just read (triggered when nothing was read), and just write: timeout, rtimeout and wtimeout, with co...
 
Note that timeout processing is active even when you do not have any outstanding read or write requests: If you plan to keep the connection idle then you should disable the timeout temporarily or ignore the timeout in the corresponding on_timeout cal...
 
Calling C<clear_timeout> (or setting it to zero, which does the same) disables the corresponding timeout.

 view all matches for this distribution


AnyEvent-Handle-Writer

 view release on metacpan or  search on metacpan

lib/AnyEvent/Handle/Writer.pm  view on Meta::CPAN

46
47
48
49
50
51
52
53
54
55
   $hdl->push_sendfile('/path/to/file', 1024);
 
=head1 RATIONALE
 
We have great l<AnyEvent::Handle>. But it have only raw write queue. This module extends it with
callbacks in write queue and adds a C<push_sendfile()> call, which would be processed at correct time
 
=head1 METHODS
 
=cut

 view all matches for this distribution


AnyEvent-I3

 view release on metacpan or  search on metacpan

lib/AnyEvent/I3.pm  view on Meta::CPAN

226
227
228
229
230
231
232
233
234
235
236
237
238
on_error => sub {
    my ($hdl, $fatal, $msg) = @_;
    delete $self->{ipchdl};
    $hdl->destroy;
 
    my $cb = $self->{callbacks};
 
    # Trigger all one-time callbacks with undef
    for my $type (keys %{$cb}) {
        next if ($type & $event_mask) == $event_mask;
        $cb->{$type}->();
        delete $cb->{$type};
    }

lib/AnyEvent/I3.pm  view on Meta::CPAN

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
}
 
sub _handle_i3_message {
    my ($self, $type, $payload) = @_;
 
    return unless defined($self->{callbacks}->{$type});
 
    my $cb = $self->{callbacks}->{$type};
    $cb->(decode_json $payload);
 
    return if ($type & $event_mask) == $event_mask;
 
    # If this was a one-time callback, we delete it
    # (when connection is lost, all one-time callbacks get triggered)
    delete $self->{callbacks}->{$type};
}
 
=head2 $i3->subscribe(\%callbacks)
 
Subscribes to the given event types. This function awaits a hashref with the
key being the name of the event and the value being a callback.
 
    my %callbacks = (
        workspace => sub { say "Workspaces changed" }
    );
 
    if ($i3->subscribe(\%callbacks)->recv->{success}) {
        say "Successfully subscribed";
    }
 
The special callback with name C<_error> is called when the connection to i3
is killed (because of a crash, exit or restart of i3 most likely). You can
use it to print an appropriate message and exit cleanly or to try to reconnect.
 
    my %callbacks = (
        _error => sub {
            my ($msg) = @_;
            say "I am sorry. I am so sorry: $msg";
            exit 1;
        }
    );
 
    $i3->subscribe(\%callbacks)->recv;
 
=cut
sub subscribe {
    my ($self, $callbacks) = @_;
 
    # Register callbacks for each message type
    for my $key (keys %{$callbacks}) {
        if (!exists $events{$key}) {
            warn "Could not subscribe to event type '$key'." .
            " Supported events are " . join(" ", sort keys %events), $/;
            next;
        }
        my $type = $events{$key};
        $self->{callbacks}->{$type} = $callbacks->{$key};
    }
 
    $self->message(TYPE_SUBSCRIBE, [ keys %{$callbacks} ])
}
 
=head2 $i3->message($type, $content)
 
Sends a message of the specified C<type> to i3, possibly containing the data

lib/AnyEvent/I3.pm  view on Meta::CPAN

360
361
362
363
364
365
366
367
368
369
370
371
372
373
    my $cv = AnyEvent->condvar;
 
    # We don’t preserve the old callback as it makes no sense to
    # have a callback on message reply types (only on events)
    $self->{callbacks}->{$type} =
        sub {
            my ($reply) = @_;
            $cv->send($reply);
            undef $self->{callbacks}->{$type};
        };
 
    $cv
}

 view all matches for this distribution


AnyEvent-IRC-Server

 view release on metacpan or  search on metacpan

t/01-simple.t  view on Meta::CPAN

10
11
12
13
14
15
16
17
18
19
20
    client => sub {
        my $port = shift;
        my $cv = AE::cv();
        my $cv_join = AE::cv();
 
        my @callbacks = (
#           sub {
#               my ($channel, $raw) = @_;
#               my $who          = $raw->{prefix} || '*';
#               my $channel_name = $raw->{params}->[0];
#               my $msg          = $raw->{params}->[1];

t/01-simple.t  view on Meta::CPAN

56
57
58
59
60
61
62
63
64
65
66
67
68
'irc_privmsg' => sub {
    # use Data::Dumper; warn Dumper($_[1]);
},
'publicmsg' => sub {
    my ($irc, $channel, $raw) = @_;
    my $cb = shift @callbacks;
    $cb->($channel, $raw);
    if (scalar(@callbacks) == 0) {
        $cv->send();
    }
},
'join' => sub {
    ok 1, 'join event';

 view all matches for this distribution


AnyEvent-IRC

 view release on metacpan or  search on metacpan

lib/AnyEvent/IRC/Client.pm  view on Meta::CPAN

993
994
995
996
997
998
999
1000
1001
1002
1003
IRC command.
 
If C<$coderef> was given and is a code reference, it will called each time a
C<$ctcp_command> is received, this is useful for eg.  CTCP PING reply
generation. The arguments will be the same arguments that the C<ctcp> event
callbacks get. (See also C<ctcp> event description above).  The return value of
the called subroutine should be a list of arguments for C<encode_ctcp>.
 
Currently you can only configure one auto-reply per C<$ctcp_command>.
 
Example:

 view all matches for this distribution


AnyEvent-Ident

 view release on metacpan or  search on metacpan

xt/author/pod_spelling_system.t  view on Meta::CPAN

42
43
44
45
46
47
48
49
50
51
52
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP

 view all matches for this distribution


AnyEvent-InfluxDB

 view release on metacpan or  search on metacpan

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
    offset => 3,
 
    # downsample result to another database, retention policy and measurement
    into => 'otherdb."default".cpu_load_per5m',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to select data: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
    duration => '7d',
    shard_duration => '30m',
    replication => 3,
    name => 'oneweek',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to create database: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
    q => "DROP DATABASE mydb",
 
    # or query created from arguments
    database => "mydb",
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop database: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
    where => q{host = 'server02'},
 
    # multiple measurements can also be specified
    measurements => [qw( cpu_load cpu_temp )],
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop measurement: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
    # or query created from arguments
    measurement => 'cpu_load',
    where => q{host = 'server02' AND time < '2016-01-01'},
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop measurement: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
    q => "DROP MEASUREMENT cpu_load",
 
    # or query created from arguments
    measurement => 'cpu_load',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop measurement: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
    q => "DROP SHARD 1",
 
    # or query created from arguments
    id => 1,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop measurement: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
$cv = AE::cv;
$db->kill_query(
    id => 36,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to kill query: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
    duration => '1d',
    shard_duration => '168h',
    replication => 1,
    default => 0,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to create retention policy: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
    duration => '1d',
    shard_duration => '12h',
    replication => 1,
    default => 1,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to alter retention policy: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
    # or query created from arguments
    name => "last_day",
    database => "mydb",
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop retention policy: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
    q => "SHOW RETENTION POLICIES ON mydb",
 
    # or query created from arguments
    database => 'mydb',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list retention policies: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
    order_by => 'region',
 
    limit => 10,
    offset => 3,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list series: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
    order_by => 'region',
 
    limit => 10,
    offset => 3,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list measurements: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
    where => q{host = 'server02'},
 
    limit => 10,
    offset => 3,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list tag keys: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
    keys => [qw( "host" "region" )],
 
    limit => 10,
    offset => 3,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list tag values: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
    q => "SHOW FIELD KEYS FROM cpu_load",
 
    # or query created from arguments
    measurement => 'cpu_load',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list field keys: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
    # or query created from arguments
    username => 'jdoe',
    password => 'mypassword',
    all_privileges => 1,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to create user: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
    # or query created from arguments
    username => 'jdoe',
    password => 'otherpassword',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to set password: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
    access => 'ALL',
 
    # or to grant cluster administration privileges
    all_privileges => 1,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to grant privileges: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
    q => "SHOW GRANTS FOR jdoe",
 
    # or query created from arguments
    username => 'jdoe',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to list users: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
    access => 'WRITE',
 
    # or to revoke cluster administration privileges
    all_privileges => 1,
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to revoke privileges: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
    q => "DROP USER jdoe",
 
    # or query created from arguments
    username => 'jdoe',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop user: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
    name => 'per5minutes',
    every => '10s',
    for => '2m',
    query => 'SELECT MEAN(value) INTO "cpu_load_per5m" FROM cpu_load GROUP BY time(5m)',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to create continuous query: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
    # or query created from arguments
    database => 'mydb',
    name => 'per5minutes',
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop continuous query: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
    mode => "ANY",
    destinations => [
        q{'udp://h1.example.com:9090'},
        q{'udp://h2.example.com:9090'}
    ],
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to create subscription: @_");
    }
);

lib/AnyEvent/InfluxDB.pm  view on Meta::CPAN

2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
    # or query created from arguments
    name => q{"alldata"},
    database => q{"mydb"},
    rp => q{"default"},
 
    # callbacks
    on_success => $cv,
    on_error => sub {
        $cv->croak("Failed to drop subscription: @_");
    }
);

 view all matches for this distribution


AnyEvent-Inotify-Simple

 view release on metacpan or  search on metacpan

lib/AnyEvent/Inotify/EventReceiver.pm  view on Meta::CPAN

44
45
46
47
48
49
50
51
52
53
54
=head2 handle_create
 
Called when a new file, C<$file>, appears in the watched directory.
If it's a directory, we automatically start watching it and calling
callbacks for files in that directory, still relative to the original
directory. C<IN_CREATE>.
 
=head2 handle_access($file)
 
Called when C<$file> is accessed. C<IN_ACCESS>.

 view all matches for this distribution


AnyEvent-JSONRPC-Lite

 view release on metacpan or  search on metacpan

lib/AnyEvent/JSONRPC/Lite/Client.pm  view on Meta::CPAN

58
59
60
61
62
63
64
65
66
67
68
        my $id = 0;
        sub { ++$id };
    },
);
 
has _callbacks => (
    is      => 'ro',
    isa     => 'HashRef',
    lazy    => 1,
    default => sub { {} },
);

lib/AnyEvent/JSONRPC/Lite/Client.pm  view on Meta::CPAN

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    }
    else {
        push @{ $self->_request_pool }, $request;
    }
 
    $self->_callbacks->{ $request->{id} } = AnyEvent->condvar;
}
 
sub _handle_response {
    my ($self, $res) = @_;
 
    my $d = delete $self->_callbacks->{ $res->{id} };
    unless ($d) {
        warn q/Invalid response from server/;
        return;
    }

 view all matches for this distribution


AnyEvent-JSONRPC

 view release on metacpan or  search on metacpan

lib/AnyEvent/JSONRPC/HTTP/Server.pm  view on Meta::CPAN

155
156
157
158
159
160
161
162
163
164
165
Listening port. Default to '8080'.
 
=back
 
=head2 reg_cb (%callbacks)
 
Register JSONRPC methods.
 
    $server->reg_cb(
        echo => sub {

 view all matches for this distribution


AnyEvent-KVStore

 view release on metacpan or  search on metacpan

lib/AnyEvent/KVStore/Hash.pm  view on Meta::CPAN

41
42
43
44
45
46
47
48
49
50
51
52
Each kvstore here has its own keyspace and watch list.
 
=head2 Watch Behavior
 
C<AnyEvent::KVStore::Hash> allows for unlimited watches to be set up, and
because this key/value store is private, the callbacks are handled synchronous
to the writes.  If you want asynchronous callbacks, you can use the
C<unblock_sub> function from L<Coro>.
 
Watches are currently indexed by the first letter of the prefix, or if no
prefix is given, an empty string.  Watches are then checked (and executed)
in order of:

lib/AnyEvent/KVStore/Hash.pm  view on Meta::CPAN

88
89
90
91
92
93
94
95
96
97
98
=head2 watch
 
In this module, watches are run synchronously, not via AnyEvent's event loop.
 
If you wish to use AnyEvent's event loop, use condition variables with
callbacks set and C<send> them.
 
=cut
 
sub read($$) {
    my ($self, $key) = @_;

 view all matches for this distribution


AnyEvent-Lingr

 view release on metacpan or  search on metacpan

lib/AnyEvent/Lingr.pm  view on Meta::CPAN

423
424
425
426
427
428
429
430
431
432
        warn $res->{message}->{id};
    });
 
=head1 CALLBACKS
 
This module supports following three callbacks:
 
=over
 
=item * on_error->($msg)

lib/AnyEvent/Lingr.pm  view on Meta::CPAN

435
436
437
438
439
440
441
442
443
444
=item * on_event->($event)
 
=back
 
All callbacks can be set by accessor:
 
    $lingr->on_error(sub { ... });
 
Or by constructor:

lib/AnyEvent/Lingr.pm  view on Meta::CPAN

448
449
450
451
452
453
454
455
456
457
        on_error => sub { ... },
    );
 
=head2 on_error->($msg)
 
Error callbacks.
 
C<$msg> is error message. If this message is form of "\d\d\d: message" like:
 
    595: Invalid argument

 view all matches for this distribution


AnyEvent-MP

 view release on metacpan or  search on metacpan

MP.pm  view on Meta::CPAN

7
8
9
10
11
12
13
14
15
16
17
 
$NODE      # contains this node's node ID
NODE       # returns this node's node ID
 
$SELF      # receiving/own port id in rcv callbacks
 
# initialise the node so it can send/receive messages
configure;
 
# ports are message destinations

MP.pm  view on Meta::CPAN

42
43
44
45
46
47
48
49
50
51
52
mon $port, $localport, @msg # send message on death
 
# temporarily execute code in port context
peval $port, sub { die "kill the port!" };
 
# execute callbacks in $SELF port context
my $timer = AE::timer 1, 0, psub {
   die "kill the port, delayed";
};
 
# distributed database - modification

MP.pm  view on Meta::CPAN

355
356
357
358
359
360
361
362
363
364
365
   # or provide a nicer-to-remember nodeid
   # aemp run profile seed nodeid "$(hostname)"
 
=item $SELF
 
Contains the current port id while executing C<rcv> callbacks or C<psub>
blocks.
 
=item *SELF, SELF, %SELF, @SELF...
 
Due to some quirks in how perl exports variables, it is impossible to

MP.pm  view on Meta::CPAN

393
394
395
396
397
398
399
400
401
402
403
these.
 
=item $local_port = port
 
Create a new local port object and returns its port ID. Initially it has
no callbacks set and will throw an error when it receives messages.
 
=item $local_port = port { my @msg = @_ }
 
Creates a new local port, and returns its ID. Semantically the same as
creating a port and calling C<rcv $port, $callback> on it.

MP.pm  view on Meta::CPAN

446
447
448
449
450
451
452
453
454
455
456
The default callback receives all messages not matched by a more specific
C<tag> match.
 
=item rcv $local_port, tag => $callback->(@msg_without_tag), ...
 
Register (or replace) callbacks to be called on messages starting with the
given tag on the given port (and return the port), or unregister it (when
C<$callback> is C<$undef> or missing). There can only be one callback
registered for each tag.
 
The original message will be passed to the callback, after the first

MP.pm  view on Meta::CPAN

578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
=item $closure = psub { BLOCK }
 
Remembers C<$SELF> and creates a closure out of the BLOCK. When the
closure is executed, sets up the environment in the same way as in C<rcv>
callbacks, i.e. runtime errors will cause the port to get C<kil>ed.
 
The effect is basically as if it returned C<< sub { peval $SELF, sub {
BLOCK }, @_ } >>.
 
This is useful when you register callbacks from C<rcv> callbacks:
 
   rcv delayed_reply => sub {
      my ($delay, @reply) = @_;
      my $timer = AE::timer $delay, 0, psub {
         snd @reply, $SELF;

MP.pm  view on Meta::CPAN

598
599
600
601
602
603
604
605
606
607
608
sub psub(&) {
   my $cb = shift;
 
   my $port = $SELF
      or Carp::croak "psub can only be called from within rcv or psub callbacks, not";
 
   sub {
      local $SELF = $port;
 
      if (wantarray) {

MP.pm  view on Meta::CPAN

753
754
755
756
757
758
759
760
761
762
(C<mon $mport, $lport> form) to get killed.
 
If a C<@reason> is specified, then linked ports (C<mon $mport, $lport>
form) get killed with the same reason.
 
Runtime errors while evaluating C<rcv> callbacks or inside C<psub> blocks
will be reported as reason C<< die => $@ >>.
 
Transport/communication errors are reported as C<< transport_error =>
$message >>.

MP.pm  view on Meta::CPAN

791
792
793
794
795
796
797
798
799
800
801
C<MyApp::Chat::Server>, C<MyApp::Chat>, C<MyApp>) until the function
exists or it runs out of package names.
 
The init function is then called with the newly-created port as context
object (C<$SELF>) and the C<@initdata> values as arguments. It I<must>
call one of the C<rcv> functions to set callbacks on C<$SELF>, otherwise
the port might not get created.
 
A common idiom is to pass a local port, immediately monitor the spawned
port, and in the remote init function, immediately monitor the passed
local port. This two-way monitoring ensures that both ports get cleaned up

 view all matches for this distribution


( run in 0.457 second using v1.01-cache-2.11-cpan-d6f9594c0a5 )