line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Iron::ClientBase; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## no critic (Documentation::RequirePodAtEnd) |
4
|
|
|
|
|
|
|
## no critic (Documentation::RequirePodSections) |
5
|
|
|
|
|
|
|
## no critic (Subroutines::RequireArgUnpacking) |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
3203
|
use 5.010_000; |
|
7
|
|
|
|
|
28
|
|
8
|
7
|
|
|
7
|
|
40
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
126
|
|
9
|
7
|
|
|
7
|
|
54
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
173
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Global creator |
12
|
|
|
|
7
|
|
|
BEGIN { |
13
|
|
|
|
|
|
|
# No exports |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Global destructor |
17
|
|
|
|
7
|
|
|
END { |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ABSTRACT: Base package for Client Libraries to Iron services IronCache, IronMQ and IronWorker. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.14'; # VERSION: generated by DZP::OurPkgVersion |
23
|
|
|
|
|
|
|
|
24
|
7
|
|
|
7
|
|
2613
|
use Log::Any qw{$log}; |
|
7
|
|
|
|
|
59595
|
|
|
7
|
|
|
|
|
35
|
|
25
|
7
|
|
|
7
|
|
15844
|
use Hash::Util 0.06 qw{lock_keys unlock_keys}; |
|
7
|
|
|
|
|
20791
|
|
|
7
|
|
|
|
|
45
|
|
26
|
7
|
|
|
7
|
|
4789
|
use Carp::Assert::More; |
|
7
|
|
|
|
|
33986
|
|
|
7
|
|
|
|
|
1327
|
|
27
|
7
|
|
|
7
|
|
3580
|
use English '-no_match_vars'; |
|
7
|
|
|
|
|
20028
|
|
|
7
|
|
|
|
|
43
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
3
|
|
|
3
|
1
|
17
|
my ($class) = @_; |
31
|
3
|
|
|
|
|
21
|
$log->tracef( 'Entering new(%s)', $class ); |
32
|
3
|
|
|
|
|
138
|
my $self = {}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# These config items are used every time when a connection to REST is made. |
35
|
3
|
|
|
|
|
14
|
my @self_keys = ( ## no critic (CodeLayout::ProhibitQuotedWordLists) |
36
|
|
|
|
|
|
|
'project_id', # The ID of the project to use for requests. |
37
|
|
|
|
|
|
|
'connection', # Reference to a IO::Iron::Connection object. |
38
|
|
|
|
|
|
|
'last_http_status_code', # Contains the HTTP return code after a successful call to the remote host. |
39
|
|
|
|
|
|
|
); |
40
|
3
|
|
|
|
|
7
|
bless $self, $class; |
41
|
3
|
|
|
|
|
5
|
lock_keys( %{$self}, @self_keys ); |
|
3
|
|
|
|
|
25
|
|
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
160
|
$log->tracef( 'Exiting new: %s', $self ); |
44
|
3
|
|
|
|
|
587
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
1
|
|
sub project_id { return $_[0]->_access_internal( 'project_id', $_[1] ); } |
48
|
0
|
|
|
0
|
1
|
|
sub connection { return $_[0]->_access_internal( 'connection', $_[1] ); } |
49
|
0
|
|
|
0
|
1
|
|
sub last_http_status_code { return $_[0]->_access_internal( 'last_http_status_code', $_[1] ); } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# INTERNAL METHODS |
52
|
|
|
|
|
|
|
# For use in the inheriting subclass |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _access_internal { |
55
|
0
|
|
|
0
|
|
|
my ( $self, $var_name, $var_value ) = @_; |
56
|
0
|
|
|
|
|
|
$log->tracef( 'Entering _access_internal(%s, %s)', $var_name, $var_value ); |
57
|
0
|
0
|
|
|
|
|
if ( defined $var_value ) { |
58
|
0
|
|
|
|
|
|
$self->{$var_name} = $var_value; |
59
|
0
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
|
return $self->{$var_name}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
IO::Iron::ClientBase - Base package for Client Libraries to Iron services IronCache, IronMQ and IronWorker. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 0.14 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SYNOPSIS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# new() in the inheriting sub class. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new { |
87
|
|
|
|
|
|
|
my ($class, $params) = @_; |
88
|
|
|
|
|
|
|
my $self = IO::Iron::ClientBase->new(); |
89
|
|
|
|
|
|
|
# Add more keys to the self hash. |
90
|
|
|
|
|
|
|
my @self_keys = ( |
91
|
|
|
|
|
|
|
'caches', # References to all objects created of class IO::Iron::IronCache::Cache. |
92
|
|
|
|
|
|
|
legal_keys(%{$self}), |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
unlock_keys(%{$self}); |
95
|
|
|
|
|
|
|
lock_keys_plus(%{$self}, @self_keys); |
96
|
|
|
|
|
|
|
my @caches; |
97
|
|
|
|
|
|
|
$self->{'caches'} = \@caches; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
unlock_keys(%{$self}); |
100
|
|
|
|
|
|
|
bless $self, $class; |
101
|
|
|
|
|
|
|
lock_keys(%{$self}, @self_keys); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return $self; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=for stopwords config Mikko Koivunalho |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 METHODS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 new |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Creator function. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Declares the mandatory items of self hash. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 Getters/setters |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Set or get a property. |
119
|
|
|
|
|
|
|
When setting, returns the reference to the object. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 8 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item project_id project_id from config. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item connection The Connection module. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item last_http_status_code |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Mikko Koivunalho <mikko.koivunalho@iki.fi> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 BUGS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Please report any bugs or feature requests to bug-io-iron@rt.cpan.org or through the web interface at: |
138
|
|
|
|
|
|
|
http://rt.cpan.org/Public/Dist/Display.html?Name=IO-Iron |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Mikko Koivunalho. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
145
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The full text of the license can be found in the |
148
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |