line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Norikra::Client; |
2
|
1
|
|
|
1
|
|
921
|
use 5.008005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
18
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
952
|
use Data::MessagePack; |
|
1
|
|
|
|
|
1353
|
|
|
1
|
|
|
|
|
48
|
|
7
|
1
|
|
|
1
|
|
533
|
use MessagePack::RPC::HTTP::Client; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $RPC_DEFAULT_PORT = 26571; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
my ($this, $host, $port, %opts) = @_; |
15
|
|
|
|
|
|
|
$host ||= "localhost"; |
16
|
|
|
|
|
|
|
$port ||= $RPC_DEFAULT_PORT; |
17
|
|
|
|
|
|
|
return bless +{client => MessagePack::RPC::HTTP::Client->new("http://$host:$port/")}, $this; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub client { |
21
|
|
|
|
|
|
|
(shift)->{client}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub targets { |
25
|
|
|
|
|
|
|
my ($self) = @_; |
26
|
|
|
|
|
|
|
$self->client->call("targets"); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub open { |
30
|
|
|
|
|
|
|
my ($self, $target, $fields, $auto_field) = @_; |
31
|
|
|
|
|
|
|
$auto_field = 1 unless defined $auto_field; |
32
|
|
|
|
|
|
|
$self->client->call("open", $target, $fields, ($auto_field ? Data::MessagePack::true() : Data::MessagePack::false() )); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub close { |
36
|
|
|
|
|
|
|
my ($self, $target) = @_; |
37
|
|
|
|
|
|
|
$self->client->call("close", $target); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub modify { |
41
|
|
|
|
|
|
|
my ($self, $target, $auto_field) = @_; |
42
|
|
|
|
|
|
|
$self->client->call("modify", $target, ($auto_field ? Data::MessagePack::true() : Data::MessagePack::false() )); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub queries { |
46
|
|
|
|
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
$self->client->call("queries"); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub register { |
51
|
|
|
|
|
|
|
my ($self, $query_name, $query_group, $query_expression) = @_; |
52
|
|
|
|
|
|
|
$self->client->call("register", $query_name, $query_group, $query_expression); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub deregister { |
56
|
|
|
|
|
|
|
my ($self, $query_name) = @_; |
57
|
|
|
|
|
|
|
$self->client->call("deregister", $query_name); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub fields { |
61
|
|
|
|
|
|
|
my ($self, $target) = @_; |
62
|
|
|
|
|
|
|
$self->client->call("fields", $target); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub reserve { |
66
|
|
|
|
|
|
|
my ($self, $target, $field, $type) = @_; |
67
|
|
|
|
|
|
|
$self->client->call("reserve", $target, $field, $type); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub send { |
71
|
|
|
|
|
|
|
my ($self, $target, $events) = @_; |
72
|
|
|
|
|
|
|
$self->client->call("send", $target, $events); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub event { |
76
|
|
|
|
|
|
|
my ($self, $query_name) = @_; |
77
|
|
|
|
|
|
|
$self->client->call("event", $query_name); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub see { |
81
|
|
|
|
|
|
|
my ($self, $query_name) = @_; |
82
|
|
|
|
|
|
|
$self->client->call("see", $query_name); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub sweep { |
86
|
|
|
|
|
|
|
my ($self, $query_group) = @_; |
87
|
|
|
|
|
|
|
$self->client->call("sweep", $query_group); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
__END__ |