Author: timbo
Date: Tue Sep 18 02:38:15 2007
New Revision: 9949
Added:
dbi/trunk/lib/DBI/Gofer/Serializer/
dbi/trunk/lib/DBI/Gofer/Serializer/Base.pm (contents, props changed)
dbi/trunk/lib/DBI/Gofer/Serializer/DataDumper.pm (contents, props changed)
dbi/trunk/lib/DBI/Gofer/Serializer/Storable.pm (contents, props changed)
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/MANIFEST
dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
Log:
Set version to 1.601
Break out gofer serializers into separate files.
Add Changes note missed from previous checkin.
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Tue Sep 18 02:38:15 2007
@@ -42,6 +42,12 @@
Call method on transport failure so transport can cleanup/reset if it wants
Gofer: gearman - need to disable coallesing for non-idempotent requests
+=head2 Changes in DBI 1.601 (svn rev XXX), XXX
+
+ Fixed t/05thrclone.t to work with Test::More >= 0.71
+ thanks to Jerry D. Hedden and Michael G Schwern.
+
+
=head2 Changes in DBI 1.59 (svn rev 9874), 23rd August 2007
Fixed DBI::ProfileData to unescape headers lines read from data file.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Tue Sep 18 02:38:15 2007
@@ -9,7 +9,7 @@
require 5.006_00;
BEGIN {
-$DBI::VERSION = "1.59"; # ==> ALSO update the version in the pod text below!
+$DBI::VERSION = "1.601"; # ==> ALSO update the version in the pod text below!
}
=head1 NAME
@@ -124,7 +124,7 @@
=head2 NOTES
-This is the DBI specification that corresponds to the DBI version 1.59
+This is the DBI specification that corresponds to the DBI version 1.601
($Revision$).
The DBI is evolving at a steady pace, so it's good to check that
Modified: dbi/trunk/MANIFEST
==============================================================================
--- dbi/trunk/MANIFEST (original)
+++ dbi/trunk/MANIFEST Tue Sep 18 02:38:15 2007
@@ -48,6 +48,9 @@
lib/DBI/Gofer/Execute.pm Execution logic for DBD::Gofer server
lib/DBI/Gofer/Request.pm Request object from DBD::Gofer
lib/DBI/Gofer/Response.pm Response object for DBD::Gofer
+lib/DBI/Gofer/Serializer/Base.pm
+lib/DBI/Gofer/Serializer/DataDumper.pm
+lib/DBI/Gofer/Serializer/Storable.pm
lib/DBI/Gofer/Transport/Base.pm Base class for DBD::Gofer server transport
classes
lib/DBI/Gofer/Transport/pipeone.pm DBD::Gofer transport for single requests
lib/DBI/Gofer/Transport/stream.pm DBI::Gofer transport for ssh etc
Added: dbi/trunk/lib/DBI/Gofer/Serializer/Base.pm
==============================================================================
--- (empty file)
+++ dbi/trunk/lib/DBI/Gofer/Serializer/Base.pm Tue Sep 18 02:38:15 2007
@@ -0,0 +1,64 @@
+package DBI::Gofer::Serializer::Base;
+
+# $Id$
+#
+# Copyright (c) 2007, Tim Bunce, Ireland
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the Perl README file.
+
+=head1 NAME
+
+DBI::Gofer::Serializer::Base - base class for Gofer serialization
+
+=head1 SYNOPSIS
+
+ $serializer = $serializer_class->new();
+
+ $string = $serializer->serialize( $data );
+ ($string, $deserializer_class) = $serializer->serialize( $data );
+
+ $data = $serializer->deserialize( $string );
+
+=head1 DESCRIPTION
+
+DBI::Gofer::Serializer::* classes implement a very minimal subset of the
L<Data::Serializer> API.
+
+Gofer serializers are expected to be very fast and are not required to deal
+with anything other than non-blessed references to arrays and hashes, and
plain scalars.
+
+=cut
+
+
+use strict;
+use warnings;
+
+use Carp qw(croak);
+
+our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
+
+
+sub new {
+ my $class = shift;
+ my $deserializer_class = $class->deserializer_class;
+ return bless { deserializer_class => $deserializer_class } => $class;
+}
+
+sub deserializer_class {
+ my $self = shift;
+ my $class = ref($self) || $self;
+ $class =~ s/^DBI::Gofer::Serializer:://;
+ return $class;
+}
+
+sub serialize {
+ my $self = shift;
+ croak ref($self)." has not implemented the serialize method";
+}
+
+sub deserialize {
+ my $self = shift;
+ croak ref($self)." has not implemented the deserialize method";
+}
+
+1;
Added: dbi/trunk/lib/DBI/Gofer/Serializer/DataDumper.pm
==============================================================================
--- (empty file)
+++ dbi/trunk/lib/DBI/Gofer/Serializer/DataDumper.pm Tue Sep 18 02:38:15 2007
@@ -0,0 +1,53 @@
+package DBI::Gofer::Serializer::DataDumper;
+
+use strict;
+use warnings;
+
+our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
+
+# $Id$
+#
+# Copyright (c) 2007, Tim Bunce, Ireland
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the Perl README file.
+
+=head1 NAME
+
+DBI::Gofer::Serializer::DataDumper - Gofer serialization using DataDumper
+
+=head1 SYNOPSIS
+
+ $serializer = DBI::Gofer::Serializer::DataDumper->new();
+
+ $string = $serializer->serialize( $data );
+
+=head1 DESCRIPTION
+
+Uses DataDumper to serialize. Deserialization is not supported.
+The output of this class is only meant for human consumption.
+
+See also L<DBI::Gofer::Serializer::Base>.
+
+=cut
+
+use Data::Dumper;
+
+use base qw(DBI::Gofer::Serializer::Base);
+
+
+sub serialize {
+ my $self = shift;
+ local $Data::Dumper::Indent = 1;
+ local $Data::Dumper::Terse = 1;
+ local $Data::Dumper::Useqq = 0; # enabling this disables xs
+ local $Data::Dumper::Sortkeys = 1;
+ local $Data::Dumper::Quotekeys = 0;
+ local $Data::Dumper::Deparse = 0;
+ local $Data::Dumper::Purity = 0;
+ my $frozen = Data::Dumper::Dumper(shift);
+ return $frozen unless wantarray;
+ return ($frozen, $self->{deserializer_class});
+}
+
+1;
Added: dbi/trunk/lib/DBI/Gofer/Serializer/Storable.pm
==============================================================================
--- (empty file)
+++ dbi/trunk/lib/DBI/Gofer/Serializer/Storable.pm Tue Sep 18 02:38:15 2007
@@ -0,0 +1,59 @@
+package DBI::Gofer::Serializer::Storable;
+
+use strict;
+use warnings;
+
+use base qw(DBI::Gofer::Serializer::Base);
+
+# $Id$
+#
+# Copyright (c) 2007, Tim Bunce, Ireland
+#
+# You may distribute under the terms of either the GNU General Public
+# License or the Artistic License, as specified in the Perl README file.
+
+=head1 NAME
+
+DBI::Gofer::Serializer::Storable - Gofer serialization using Storable
+
+=head1 SYNOPSIS
+
+ $serializer = DBI::Gofer::Serializer::Storable->new();
+
+ $string = $serializer->serialize( $data );
+ ($string, $deserializer_class) = $serializer->serialize( $data );
+
+ $data = $serializer->deserialize( $string );
+
+=head1 DESCRIPTION
+
+Uses Storable::nfreeze() to serialize and Storable::thaw() to deserialize.
+
+The serialize() method sets local $Storable::forgive_me = 1; so it doesn't
+croak if it encounters any data types that can't be serialized, such as code
refs.
+
+See also L<DBI::Gofer::Serializer::Base>.
+
+=cut
+
+use Storable qw(nfreeze thaw);
+
+our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
+
+use base qw(DBI::Gofer::Serializer::Base);
+
+
+sub serialize {
+ my $self = shift;
+ local $Storable::forgive_me = 1; # for CODE refs etc
+ my $frozen = nfreeze(shift);
+ return $frozen unless wantarray;
+ return ($frozen, $self->{deserializer_class});
+}
+
+sub deserialize {
+ my $self = shift;
+ return thaw(shift);
+}
+
+1;
Modified: dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/Base.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/Base.pm Tue Sep 18 02:38:15 2007
@@ -14,6 +14,10 @@
use base qw(DBI::Util::_accessor);
+use DBI::Gofer::Serializer::Storable;
+use DBI::Gofer::Serializer::DataDumper;
+
+
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
@@ -37,55 +41,6 @@
return $self;
}
-{ package DBI::Gofer::Serializer::Storable;
- # a very minimal subset of Data::Serializer
- use Storable qw(nfreeze thaw);
- sub new {
- return bless {} => shift;
- }
- sub serialize {
- my $self = shift;
- local $Storable::forgive_me = 1; # for CODE refs etc
- return nfreeze(shift);
- }
- sub deserialize {
- my $self = shift;
- return thaw(shift);
- }
-}
-
-{ package DBI::Gofer::Serializer::DataDumper;
- # a very minimal subset of Data::Serializer
- require Data::Dumper;
- sub new {
- local $Data::Dumper::Indent = 1;
- local $Data::Dumper::Terse = 1;
- local $Data::Dumper::Useqq = 0; # enabling this disables xs
- local $Data::Dumper::Sortkeys = 1;
- local $Data::Dumper::Quotekeys = 0;
- local $Data::Dumper::Deparse = 0;
- local $Data::Dumper::Purity = 0;
- return bless {
- dumper => Data::Dumper->new([], undef),
- } => shift;
- }
- sub serialize {
- my $dumper = shift->{dumper};
- local $Data::Dumper::Indent = 1;
- local $Data::Dumper::Terse = 1;
- local $Data::Dumper::Useqq = 0; # enabling this disables xs
- local $Data::Dumper::Sortkeys = 1;
- local $Data::Dumper::Quotekeys = 0;
- local $Data::Dumper::Deparse = 0;
- local $Data::Dumper::Purity = 0;
- return Data::Dumper::Dumper(shift);
- }
- sub deserialize {
- Carp::croak("deserialize not supported for ".__PACKAGE__);
- }
-}
-
-
my $packet_header_text = "GoFER1:";
my $packet_header_regex = qr/^GoFER(\d+):/;
@@ -98,7 +53,7 @@
local $data->{meta}; # don't include _meta in serialization
$serializer ||= $self->{serializer_obj};
- my $data = $serializer->serialize($data);
+ my ($data, $deserializer_class) = $serializer->serialize($data);
$packet_header_text . $data;
};