[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 package DBD::Gofer::Transport::null; 2 3 # $Id: null.pm 10087 2007-10-16 12:42:37Z timbo $ 4 # 5 # Copyright (c) 2007, Tim Bunce, Ireland 6 # 7 # You may distribute under the terms of either the GNU General Public 8 # License or the Artistic License, as specified in the Perl README file. 9 10 use strict; 11 use warnings; 12 13 use base qw(DBD::Gofer::Transport::Base); 14 15 use DBI::Gofer::Execute; 16 17 our $VERSION = sprintf("0.%06d", q$Revision: 10087 $ =~ /(\d+)/o); 18 19 __PACKAGE__->mk_accessors(qw( 20 pending_response 21 transmit_count 22 )); 23 24 my $executor = DBI::Gofer::Execute->new(); 25 26 27 sub transmit_request_by_transport { 28 my ($self, $request) = @_; 29 $self->transmit_count( ($self->transmit_count()||0) + 1 ); # just for tests 30 31 my $frozen_request = $self->freeze_request($request); 32 33 # ... 34 # the request is magically transported over to ... ourselves 35 # ... 36 37 my $response = $executor->execute_request( $self->thaw_request($frozen_request, undef, 1) ); 38 39 # put response 'on the shelf' ready for receive_response() 40 $self->pending_response( $response ); 41 42 return undef; 43 } 44 45 46 sub receive_response_by_transport { 47 my $self = shift; 48 49 my $response = $self->pending_response; 50 51 my $frozen_response = $self->freeze_response($response, undef, 1); 52 53 # ... 54 # the response is magically transported back to ... ourselves 55 # ... 56 57 return $self->thaw_response($frozen_response); 58 } 59 60 61 1; 62 __END__ 63 64 =head1 NAME 65 66 DBD::Gofer::Transport::null - DBD::Gofer client transport for testing 67 68 =head1 SYNOPSIS 69 70 my $original_dsn = "..." 71 DBI->connect("dbi:Gofer:transport=null;dsn=$original_dsn",...) 72 73 or, enable by setting the DBI_AUTOPROXY environment variable: 74 75 export DBI_AUTOPROXY="dbi:Gofer:transport=null" 76 77 =head1 DESCRIPTION 78 79 Connect via DBD::Gofer but execute the requests within the same process. 80 81 This is a quick and simple way to test applications for compatibility with the 82 (few) restrictions that DBD::Gofer imposes. 83 84 It also provides a simple, portable way for the DBI test suite to be used to 85 test DBD::Gofer on all platforms with no setup. 86 87 Also, by measuring the difference in performance between normal connections and 88 connections via C<dbi:Gofer:transport=null> the basic cost of using DBD::Gofer 89 can be measured. Furthermore, the additional cost of more advanced transports can be 90 isolated by comparing their performance with the null transport. 91 92 The C<t/85gofer.t> script in the DBI distribution includes a comparative benchmark. 93 94 =head1 AUTHOR 95 96 Tim Bunce, L<http://www.tim.bunce.name> 97 98 =head1 LICENCE AND COPYRIGHT 99 100 Copyright (c) 2007, Tim Bunce, Ireland. All rights reserved. 101 102 This module is free software; you can redistribute it and/or 103 modify it under the same terms as Perl itself. See L<perlartistic>. 104 105 =head1 SEE ALSO 106 107 L<DBD::Gofer::Transport::Base> 108 109 L<DBD::Gofer> 110 111 =cut
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |