1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
# $Id$
package Recipe;
use strict;
use base qw( Data::ObjectDriver::BaseObject );
use DodTestUtil;
use Data::ObjectDriver::Driver::DBI;
__PACKAGE__->install_properties({
columns => [ 'recipe_id', 'partition_id', 'title' ],
datasource => 'recipes',
primary_key => 'recipe_id',
driver => Data::ObjectDriver::Driver::DBI->new(
dsn => DodTestUtil::dsn('global'),
reuse_dbh => 1,
),
});
my %drivers;
__PACKAGE__->has_partitions(
number => 2,
get_driver => sub {
my $cluster = shift;
my $driver = $drivers{$cluster} ||=
Data::ObjectDriver::Driver::DBI->new(
dsn => DodTestUtil::dsn('cluster' . $cluster),
reuse_dbh => 1,
@_,
);
return $driver;
},
);
1;
|