source: response/varnish-tools/perl/Varnish-API/lib/Varnish/API.pm @ a3a4bf

Revision a3a4bf, 3.3 KB checked in by Artur Bergman <sky@…>, 5 years ago (diff)

synthetic non error resposnes

git-svn-id:  http://www.varnish-cache.org/svn/branches/sky@4148 d4fa192b-c00b-0410-8231-f00ffab90ce4

  • Property mode set to 100644
Line 
1package Varnish::API;
2
3use 5.008008;
4use strict;
5use warnings;
6use Carp;
7
8require Exporter;
9use AutoLoader;
10
11our @ISA = qw(Exporter);
12
13# Items to export into callers namespace by default. Note: do not export
14# names by default without a very good reason. Use EXPORT_OK instead.
15# Do not simply export all your public functions/methods/constants.
16
17# This allows declaration       use Varnish::API ':all';
18# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19# will save memory.
20our %EXPORT_TAGS = ( 'all' => [ qw(
21        VSL_S_BACKEND
22        VSL_S_CLIENT
23        V_DEAD
24        VSL_Arg
25        VSL_Dispatch
26        VSL_Name
27        VSL_New
28        VSL_NextLog
29        VSL_NonBlocking
30        VSL_OpenLog
31        VSL_OpenStats
32        VSL_Select
33        asctime
34        asctime_r
35        base64_decode
36        base64_init
37        clock
38        clock_getcpuclockid
39        clock_getres
40        clock_gettime
41        clock_nanosleep
42        clock_settime
43        ctime
44        ctime_r
45        difftime
46        dysize
47        getdate
48        getdate_r
49        gmtime
50        gmtime_r
51        localtime
52        localtime_r
53        mktime
54        nanosleep
55        stime
56        strftime
57        strftime_l
58        strptime
59        strptime_l
60        time
61        timegm
62        timelocal
63        timer_create
64        timer_delete
65        timer_getoverrun
66        timer_gettime
67        timer_settime
68        tzset
69        varnish_instance
70) ] );
71
72our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
73
74our @EXPORT = qw(
75        VSL_S_BACKEND
76        VSL_S_CLIENT
77        V_DEAD
78);
79
80our $VERSION = '1.99';
81
82sub AUTOLOAD {
83    # This AUTOLOAD is used to 'autoload' constants from the constant()
84    # XS function.
85
86    my $constname;
87    our $AUTOLOAD;
88    ($constname = $AUTOLOAD) =~ s/.*:://;
89    croak "&Varnish::API::constant not defined" if $constname eq 'constant';
90    my ($error, $val) = constant($constname);
91    if ($error) { croak $error; }
92    {
93        no strict 'refs';
94        # Fixed between 5.005_53 and 5.005_61
95#XXX    if ($] >= 5.00561) {
96#XXX        *$AUTOLOAD = sub () { $val };
97#XXX    }
98#XXX    else {
99            *$AUTOLOAD = sub { $val };
100#XXX    }
101    }
102    goto &$AUTOLOAD;
103}
104
105require XSLoader;
106XSLoader::load('Varnish::API', $VERSION);
107
108# Preloaded methods go here.
109
110# Autoload methods go after =cut, and are processed by the autosplit program.
111
1121;
113__END__
114# Below is stub documentation for your module. You'd better edit it!
115
116=head1 NAME
117
118Varnish::API - Perl extension for accessing varnish stats and logs
119
120=head1 SYNOPSIS
121
122  use Varnish::API;
123  use Sys::Hostname qw(hostname);
124
125  my $vd = Varnish::API::VSL_New();
126  Varnish::API::VSL_OpenLog($vd, hostname);
127
128  Varnish::API::VSL_Dispatch($vd,
129    sub { my ($tag, $id, $spec, $text) = @_; return 1 });
130
131  my $log = Varnish::API::VSL_NextLog($vd);
132  my $tag = Varnish::API::VSL_tags(Varnish::API::SHMLOG_TAG($log));
133  my $fd  = Varnish::API::SHMLOG_ID($log);
134  my $text = Varnish::API::SHMLOG_DATA($log);
135
136  my $stats = Varnish::API::VSL_OpenStats(hostname);
137  my $fields = Varnish::API::VSL_GetStatFieldTypes();
138  my $description = Varnish::API::VSL_GetStatFieldDescriptions();
139  my $client_conn = Varnish::API::VSL_GetStat($stats, "client_conn");
140
141
142=head1 DESCRIPTION
143
144This module allows access to the data that varnishlog and varnishstats can read.
145
146=head2 EXPORT
147
148None by default.
149
150=head1 SEE ALSO
151
152=head1 AUTHOR
153
154Artur Bergman E<lt>sky+cpan@crucially.netE<gt>
155
156=head1 COPYRIGHT AND LICENSE
157
158Copyright (C) 2009 by Artur Bergman
159
160This library is free software; you can redistribute it and/or modify
161it under the same terms as Perl itself, either Perl version 5.8.8 or,
162at your option, any later version of Perl 5 you may have available.
163
164
165=cut
Note: See TracBrowser for help on using the repository browser.