| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
20
|
|
|
20
|
|
232
|
use v5.12; |
|
|
20
|
|
|
|
|
62
|
|
|
2
|
20
|
|
|
20
|
|
121
|
use warnings; |
|
|
20
|
|
|
|
|
32
|
|
|
|
20
|
|
|
|
|
1660
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Neo4j::Driver::Events 1.02; |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Event manager for Neo4j::Driver plug-ins |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# This package is not part of the public Neo4j::Driver API. |
|
9
|
|
|
|
|
|
|
# (except as far as documented in Plugin.pm) |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
20
|
|
|
20
|
|
142
|
use Carp qw(croak); |
|
|
20
|
|
|
|
|
35
|
|
|
|
20
|
|
|
|
|
1716
|
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw( |
|
14
|
|
|
|
|
|
|
Neo4j::Driver::Result::Bolt |
|
15
|
|
|
|
|
|
|
Neo4j::Driver::Result::Jolt |
|
16
|
|
|
|
|
|
|
Neo4j::Driver::Result::JSON |
|
17
|
|
|
|
|
|
|
Neo4j::Driver::Result::Text |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
20
|
|
|
20
|
|
122
|
use Scalar::Util qw(weaken); |
|
|
20
|
|
|
|
|
53
|
|
|
|
20
|
|
|
|
|
14430
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $STACK_TRACE = 0; # die with stack trace on error; for debugging only |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
|
|
|
|
|
|
# uncoverable pod |
|
28
|
194
|
|
|
194
|
0
|
407880
|
my ($class) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
194
|
|
|
|
|
483
|
my $self = bless {}, $class; |
|
31
|
194
|
|
|
|
|
771
|
$self->_init_default_handlers; |
|
32
|
194
|
|
|
|
|
926
|
return $self; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Set up the default handlers for generic events when creating the manager. |
|
37
|
|
|
|
|
|
|
sub _init_default_handlers { |
|
38
|
194
|
|
|
194
|
|
434
|
my ($self) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->{default_handlers}->{error} = sub { |
|
41
|
|
|
|
|
|
|
# Unlike regular handlers, default handlers don't receive a callback. |
|
42
|
21
|
|
|
21
|
|
52
|
my ($error) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
21
|
50
|
|
|
|
63
|
die $error->trace if $STACK_TRACE; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Join all errors into a multi-line string for backwards compatibility with pre-0.36. |
|
47
|
21
|
|
|
|
|
34
|
my @errors; |
|
48
|
21
|
|
|
|
|
39
|
do { push @errors, $error } while $error = $error->related; |
|
|
28
|
|
|
|
|
213
|
|
|
49
|
21
|
|
|
|
|
144
|
@errors = map { $_->as_string } @errors; |
|
|
28
|
|
|
|
|
136
|
|
|
50
|
21
|
|
|
|
|
546
|
croak join "\n", @errors; |
|
51
|
194
|
|
|
|
|
1421
|
}; |
|
52
|
194
|
|
|
|
|
514
|
weaken $self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub add_handler { |
|
57
|
|
|
|
|
|
|
# uncoverable pod (see Plugin.pm) |
|
58
|
109
|
|
|
109
|
0
|
10134
|
my ($self, $event, $handler, @extra) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
109
|
100
|
|
|
|
350
|
croak "Too many arguments for method 'add_handler'" if @extra; |
|
61
|
107
|
100
|
|
|
|
351
|
croak "Event handler must be a subroutine reference" unless ref $handler eq 'CODE'; |
|
62
|
104
|
100
|
|
|
|
346
|
croak "Event name must be defined" unless defined $event; |
|
63
|
|
|
|
|
|
|
|
|
64
|
103
|
|
|
|
|
212
|
push @{$self->{handlers}->{$event}}, $handler; |
|
|
103
|
|
|
|
|
620
|
|
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub trigger { |
|
69
|
|
|
|
|
|
|
# uncoverable pod (see Plugin.pm) |
|
70
|
234
|
|
|
234
|
0
|
50277
|
my ($self, $event, @params) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
234
|
|
|
|
|
562
|
my $default_handler = $self->{default_handlers}->{$event}; |
|
73
|
234
|
100
|
|
|
|
887
|
my $handlers = $self->{handlers}->{$event} |
|
|
|
100
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
or return $default_handler ? $default_handler->(@params) : (); |
|
75
|
|
|
|
|
|
|
|
|
76
|
198
|
|
66
|
3
|
|
555
|
my $callback = $default_handler // sub {}; |
|
77
|
198
|
|
|
|
|
496
|
for my $handler ( reverse @$handlers ) { |
|
78
|
205
|
|
|
|
|
352
|
my $continue = $callback; |
|
79
|
205
|
|
|
202
|
|
1060
|
$callback = sub { $handler->($continue, @params) }; |
|
|
202
|
|
|
|
|
1729
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
198
|
|
|
|
|
406
|
return $callback->(); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Right now, ALL events get a continuation callback. |
|
84
|
|
|
|
|
|
|
# But this will almost certainly change eventually. |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Tell a new plugin to register itself using this manager. |
|
89
|
|
|
|
|
|
|
sub _register_plugin { |
|
90
|
94
|
|
|
94
|
|
11990
|
my ($self, $plugin) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
94
|
100
|
|
|
|
1185
|
croak sprintf "Package %s is not a Neo4j::Driver::Plugin", $plugin unless $plugin->DOES('Neo4j::Driver::Plugin'); |
|
93
|
91
|
100
|
|
|
|
582
|
croak sprintf "Method register() not implemented by package %s (is this a Neo4j::Driver plug-in?)", $plugin unless $plugin->can('register'); |
|
94
|
90
|
100
|
|
|
|
1922
|
croak "Neo4j::Driver->plugin() requires a plug-in object" unless ref $plugin ne ''; |
|
95
|
|
|
|
|
|
|
|
|
96
|
89
|
|
|
|
|
377
|
$plugin->register($self); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |