# POD is generated automatically by calling _gen_pod from the
# Makefile.PL in $AUTHOR mode
-# *DELIBERATELY* not making a group for these - they must disappear
-# forever as optdeps in the first place
-my $moose_basic = {
- 'Moose' => '0.98',
- 'MooseX::Types' => '0.21',
- 'MooseX::Types::LoadableClass' => '0.011',
-};
-
my $dbic_reqs = {
# NOTE: the rationale for 2 JSON::Any versions is that
},
replicated => {
- req => $moose_basic,
+ req => {
+ 'Class::Load' => '0.20',
+ },
pod => {
title => 'Storage::Replicated',
desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
test_replicated => {
include => 'replicated',
- req => {
- 'Test::Moose' => '0',
- },
},
admin => {
package DBIx::Class::Storage::DBI::Replicated;
-use warnings;
-use strict;
-
-BEGIN {
- require DBIx::Class::Optional::Dependencies;
- if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('replicated') ) {
- die "The following modules are required for Replicated storage support: $missing\n";
- }
-}
-
-use Moose;
+use Moo;
use DBIx::Class::Storage::DBI;
use DBIx::Class::Storage::DBI::Replicated::Pool;
use DBIx::Class::Storage::DBI::Replicated::Balancer;
-use DBIx::Class::Storage::DBI::Replicated::Types qw/BalancerClassNamePart DBICSchema DBICStorageDBI/;
-use MooseX::Types::Moose qw/ClassName HashRef Object/;
-use Scalar::Util 'reftype';
+use DBIx::Class::_Types qw/BalancerClassNamePart LoadableClass HashRef Object DBICSchema DBICStorageDBI/;
+use Scalar::Util qw(reftype blessed);
+use Sub::Name qw(subname);
use Hash::Merge;
use List::Util qw/min max reduce/;
use Context::Preserve 'preserve_context';
+use Class::Inspector;
use Try::Tiny;
-use namespace::clean -except => 'meta';
+use namespace::clean;
=head1 NAME
has 'pool_type' => (
is=>'rw',
- isa=>ClassName,
+ isa=>LoadableClass,
default=>'DBIx::Class::Storage::DBI::Replicated::Pool',
handles=>{
'create_pool' => 'new',
has 'balancer_type' => (
is=>'rw',
- isa=>BalancerClassNamePart,
- coerce=>1,
+ isa=>BalancerClassNamePart(coerce=>1),
required=>1,
default=> 'DBIx::Class::Storage::DBI::Replicated::Balancer::First',
handles=>{
is=>'rw',
isa=>HashRef,
lazy=>1,
- required=>1,
default=>sub { {} },
);
has 'pool' => (
is=>'ro',
- isa=>'DBIx::Class::Storage::DBI::Replicated::Pool',
- lazy_build=>1,
+ isa=>Object, # 'DBIx::Class::Storage::DBI::Replicated::Pool',
+ lazy=>1,
+ builder=>1,
+ clearer=>1,
handles=>[qw/
connect_replicants
replicants
has 'balancer' => (
is=>'rw',
- isa=>'DBIx::Class::Storage::DBI::Replicated::Balancer',
- lazy_build=>1,
+ isa=>Object, # 'DBIx::Class::Storage::DBI::Replicated::Balancer',
+ lazy=>1,
+ builder=>1,
handles=>[qw/auto_validate_every/],
);
has 'master' => (
is=> 'ro',
isa=>DBICStorageDBI,
- lazy_build=>1,
+ lazy=>1,
+ builder=>1,
);
=head1 ATTRIBUTES IMPLEMENTING THE DBIx::Storage::DBI INTERFACE
_execute
_do_query
_dbh_execute
- /, Class::MOP::Class->initialize('DBIx::Class::Storage::DBIHacks')->get_method_list ],
+ /, @{Class::Inspector->functions('DBIx::Class::Storage::DBIHacks')} ],
reader => [qw/
select
select_single
_bind_sth_params
/,(
# the capability framework
- # not sure if CMOP->initialize does evil things to DBIC::S::DBI, fix if a problem
grep
{ $_ =~ /^ _ (?: use | supports | determine_supports ) _ /x and $_ ne '_use_multicolumn_in' }
- ( Class::MOP::Class->initialize('DBIx::Class::Storage::DBI')->get_all_method_names )
+ @{Class::Inspector->functions('DBIx::Class::Storage::DBI')}
)],
};
}
for my $method (@{$method_dispatch->{unimplemented}}) {
- __PACKAGE__->meta->add_method($method, sub {
+ no strict 'refs';
+ *{$method} = subname $method => sub {
my $self = shift;
$self->throw_exception("$method() must not be called on ".(blessed $self).' objects');
- });
+ };
}
=head2 read_handler
has 'read_handler' => (
is=>'rw',
isa=>Object,
- lazy_build=>1,
+ lazy=>1,
+ builder=>1,
handles=>$method_dispatch->{reader},
);
has 'write_handler' => (
is=>'ro',
isa=>Object,
- lazy_build=>1,
+ lazy=>1,
+ builder=>1,
handles=>$method_dispatch->{writer},
);
# Make sure master is blessed into the correct class and apply role to it.
my $master = $self->master;
$master->_determine_driver;
- Moose::Meta::Class->initialize(ref $master);
- DBIx::Class::Storage::DBI::Replicated::WithDSN->meta->apply($master);
+ Moo::Role->apply_roles_to_object($master, 'DBIx::Class::Storage::DBI::Replicated::WithDSN');
# link pool back to master
$self->pool->master($master);
=cut
-__PACKAGE__->meta->make_immutable;
-
1;
package DBIx::Class::Storage::DBI::Replicated::Balancer;
-use Moose::Role;
+use Moo::Role;
requires 'next_storage';
-use MooseX::Types::Moose qw/Int/;
+
+use DBIx::Class::_Types qw(PositiveInteger DBICStorageDBI DBICStorageDBIReplicatedPool);
use DBIx::Class::Storage::DBI::Replicated::Pool;
-use DBIx::Class::Storage::DBI::Replicated::Types qw/DBICStorageDBI/;
-use namespace::clean -except => 'meta';
+use Scalar::Util qw(blessed);
+
+use namespace::clean;
=head1 NAME
has 'auto_validate_every' => (
is=>'rw',
- isa=>Int,
+ isa=>PositiveInteger,
predicate=>'has_auto_validate_every',
);
has 'pool' => (
is=>'ro',
- isa=>'DBIx::Class::Storage::DBI::Replicated::Pool',
+ isa=>DBICStorageDBIReplicatedPool,
required=>1,
);
has 'current_replicant' => (
is=> 'rw',
isa=>DBICStorageDBI,
- lazy_build=>1,
+ lazy=>1,
+ builder=>1,
handles=>[qw/
select
select_single
package DBIx::Class::Storage::DBI::Replicated::Balancer::First;
-use Moose;
+use Moo;
with 'DBIx::Class::Storage::DBI::Replicated::Balancer';
-use namespace::clean -except => 'meta';
+use namespace::clean;
=head1 NAME
=cut
-__PACKAGE__->meta->make_immutable;
-
1;
package DBIx::Class::Storage::DBI::Replicated::Balancer::Random;
-use Moose;
+use Moo;
with 'DBIx::Class::Storage::DBI::Replicated::Balancer';
-use DBIx::Class::Storage::DBI::Replicated::Types 'Weight';
-use namespace::clean -except => 'meta';
+use DBIx::Class::_Types qw(PositiveNumber);
+
+use namespace::clean;
=head1 NAME
=cut
-has master_read_weight => (is => 'rw', isa => Weight, default => sub { 0 });
+has master_read_weight => (is => 'rw', isa => PositiveNumber, default => sub { 0 });
=head1 METHODS
=cut
-__PACKAGE__->meta->make_immutable;
-
1;
package DBIx::Class::Storage::DBI::Replicated::Pool;
-use Moose;
+use Moo;
use DBIx::Class::Storage::DBI::Replicated::Replicant;
use List::Util 'sum';
use Scalar::Util 'reftype';
use DBI ();
-use MooseX::Types::Moose qw/Num Int ClassName HashRef/;
-use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI';
+use DBIx::Class::_Types qw(HashRef Number Integer LoadableClass DBICStorageDBI);
use Try::Tiny;
-use namespace::clean -except => 'meta';
+use namespace::clean;
=head1 NAME
has 'maximum_lag' => (
is=>'rw',
- isa=>Num,
- required=>1,
+ isa=>Number,
lazy=>1,
- default=>0,
+ default=>sub { 0 },
);
=head2 last_validated
has 'last_validated' => (
is=>'rw',
- isa=>Int,
+ isa=>Integer,
reader=>'last_validated',
writer=>'_last_validated',
lazy=>1,
- default=>0,
+ default=>sub { 0 },
);
=head2 replicant_type ($classname)
has 'replicant_type' => (
is=>'ro',
- isa=>ClassName,
+ isa=>LoadableClass,
required=>1,
default=>'DBIx::Class::Storage::DBI',
handles=>{
has 'replicants' => (
is=>'rw',
- traits => ['Hash'],
- isa=>HashRef['Object'],
+ isa=>HashRef,
default=>sub {{}},
- handles => {
- 'set_replicant' => 'set',
- 'get_replicant' => 'get',
- 'has_replicants' => 'is_empty',
- 'num_replicants' => 'count',
- 'delete_replicant' => 'delete',
- 'all_replicant_storages' => 'values',
- },
);
-around has_replicants => sub {
- my ($orig, $self) = @_;
- return !$self->$orig;
-};
+sub set_replicant { $_[0]->replicants->{$_[1]} = $_[2] }
+sub get_replicant { $_[0]->replicants->{$_[1]} }
+sub has_replicants { !!keys %{$_[0]->replicants} }
+sub num_replicants { 0+keys %{$_[0]->replicants} }
+sub delete_replicant { delete $_[0]->replicants->{$_[1]} }
+sub all_replicant_storages { values %{$_[0]->replicants} }
has next_unknown_replicant_id => (
is => 'rw',
- traits => ['Counter'],
- isa => Int,
+ isa => Integer,
default => 1,
- handles => {
- 'inc_unknown_replicant_id' => 'inc',
- },
);
+sub inc_unknown_replicant_id {
+ my ($self) = @_;
+ $self->next_unknown_replicant_id($self->next_unknown_replicant_id + 1);
+}
+
=head2 master
Reference to the master Storage.
$replicant->_determine_driver
});
- Moose::Meta::Class->initialize(ref $replicant);
-
- DBIx::Class::Storage::DBI::Replicated::Replicant->meta->apply($replicant);
+ Moo::Role->apply_roles_to_object($replicant, 'DBIx::Class::Storage::DBI::Replicated::Replicant');
# link back to master
$replicant->master($self->master);
=cut
-__PACKAGE__->meta->make_immutable;
-
1;
package DBIx::Class::Storage::DBI::Replicated::Replicant;
-use Moose::Role;
+use Moo::Role;
requires qw/_query_start/;
with 'DBIx::Class::Storage::DBI::Replicated::WithDSN';
-use MooseX::Types::Moose qw/Bool Str/;
-use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI';
+use DBIx::Class::_Types qw(Bool Str DBICStorageDBI);
-use namespace::clean -except => 'meta';
+use namespace::clean;
=head1 NAME
+++ /dev/null
-package # hide from PAUSE
- DBIx::Class::Storage::DBI::Replicated::Types;
-
-# DBIx::Class::Storage::DBI::Replicated::Types - Types used internally by
-# L<DBIx::Class::Storage::DBI::Replicated>
-
-# Workaround for https://rt.cpan.org/Public/Bug/Display.html?id=83336
-use warnings;
-use strict;
-
-use MooseX::Types
- -declare => [qw/BalancerClassNamePart Weight DBICSchema DBICStorageDBI/];
-use MooseX::Types::Moose qw/ClassName Str Num/;
-use MooseX::Types::LoadableClass qw/LoadableClass/;
-
-class_type 'DBIx::Class::Storage::DBI';
-class_type 'DBIx::Class::Schema';
-
-subtype DBICSchema, as 'DBIx::Class::Schema';
-subtype DBICStorageDBI, as 'DBIx::Class::Storage::DBI';
-
-subtype BalancerClassNamePart,
- as LoadableClass;
-
-coerce BalancerClassNamePart,
- from Str,
- via {
- my $type = $_;
- $type =~ s/\A::/DBIx::Class::Storage::DBI::Replicated::Balancer::/;
- $type;
- };
-
-subtype Weight,
- as Num,
- where { $_ >= 0 },
- message { 'weight must be a decimal greater than 0' };
-
-1;
package DBIx::Class::Storage::DBI::Replicated::WithDSN;
-use Moose::Role;
+use Moo::Role;
use Scalar::Util 'reftype';
requires qw/_query_start/;
use Try::Tiny;
-use namespace::clean -except => 'meta';
+
+use namespace::clean;
=head1 NAME
unless(Object(@_) && $_[0]->does('DBIx::Class::Storage::DBI::Replicated::Balancer') );
}
+sub BalancerClassNamePart {
+ LoadableClass(@_);
+}
+
+sub coerce_BalancerClassNamePart {
+ (my $name = $_[0] || '') =~ s/\A::/DBIx::Class::Storage::DBI::Replicated::Balancer::/;
+ $name;
+}
+
1;
parallel_installdeps_notest Test::Warn B::Hooks::EndOfScope Test::Differences HTTP::Status
parallel_installdeps_notest Test::Pod::Coverage Test::EOL Devel::GlobalDestruction Sub::Name MRO::Compat Class::XSAccessor URI::Escape HTML::Entities
parallel_installdeps_notest YAML LWP Class::Trigger DateTime::Format::Builder Class::Accessor::Grouped Package::Variant
- parallel_installdeps_notest SQL::Abstract Moose Module::Install@1.15 JSON SQL::Translator File::Which Class::DBI::Plugin
+ parallel_installdeps_notest SQL::Abstract Module::Install@1.15 JSON SQL::Translator File::Which Class::DBI::Plugin
# the official version is very much outdated and does not compile on 5.14+
# use this rather updated source tree (needs to go to PAUSE):
if [[ "$DEVREL_DEPS" == "true" ]] && perl -M5.008003 -e1 &>/dev/null ; then
# FIXME - these really need to be installed *with* testing under "allowed failures"
- # Change when Moose goes away
- parallel_installdeps_notest Moose
parallel_installdeps_notest $(perl -Ilib -MDBIx::Class::Optional::Dependencies=-list_missing,dist_dir)
run_or_err "Attempt to build a dist" "rm -rf inc/ && perl Makefile.PL --skip-author-deps && make dist"
# undo some of the pollution (if any) affecting the plain install deps
- # FIXME - this will go away once we move off Moose, and a new SQLT
- # with much less recommends ships
+ # FIXME - this will go away once a new SQLT with much less recommends ships
export DBICTEST_SQLT_DEPLOY=""
- export DBICTEST_VIA_REPLICATED=""
# make sure we are retrying with newest CPAN possible
use warnings;
use Test::More;
-use DBIx::Class::_Util 'modver_gt_or_eq_and_lt';
use lib qw(t/lib);
use DBICTest;
-
-BEGIN {
- plan skip_all => "A trial version of Moose detected known to break replication - skipping test known to fail" if (
- DBICTest::RunMode->is_smoker
- and
- modver_gt_or_eq_and_lt( 'Moose', '1.99', '1.9903' )
- )
-}
-
-use Test::Moose;
use Test::Exception;
use List::Util 'first';
use Scalar::Util 'reftype';
+use Class::Inspector;
use File::Spec;
-use Moose();
-use MooseX::Types();
-note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION";
+use Moo::Role ();
+use IO::Handle;
my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) );
{
package DBIx::Class::Storage::DBI::Replicated;
- use Moose;
-
- __PACKAGE__->meta->make_mutable;
+ use Moo;
around connect_info => sub {
my ($next, $self, $info) = @_;
$self->$next($info);
};
- __PACKAGE__->meta->make_immutable;
-
- no Moose;
}
-
+sub does_ok ($$;$) {
+ my ($thing, $role, $desc) = @_;
+ $desc ||= "The object does $role";
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ ok Moo::Role::does_role($thing, $role), $desc;
+}
=head1 HOW TO USE
### check that all Storage::DBI methods are handled by ::Replicated
{
- my @storage_dbi_methods = Class::MOP::Class
- ->initialize('DBIx::Class::Storage::DBI')->get_all_method_names;
+ my @storage_dbi_methods = @{Class::Inspector->methods('DBIx::Class::Storage::DBI')};
- my @replicated_methods = DBIx::Class::Storage::DBI::Replicated->meta
- ->get_all_method_names;
+ my @replicated_methods = @{Class::Inspector->methods('DBIx::Class::Storage::DBI::Replicated')};
# remove constants and OTHER_CRAP
@storage_dbi_methods = grep !/^[A-Z_]+\z/, @storage_dbi_methods;
@storage_dbi_methods = grep !/_accessor\z/, @storage_dbi_methods;
# remove DBIx::Class (the root parent, with CAG and stuff) methods
- my @root_methods = Class::MOP::Class->initialize('DBIx::Class')
- ->get_all_method_names;
+ my @root_methods = @{Class::Inspector->methods('DBIx::Class')};
my %count;
$count{$_}++ for (@storage_dbi_methods, @root_methods);
}
}
-ok $replicated->schema->storage->meta
- => 'has a meta object';
-
isa_ok $replicated->schema->storage->master
=> 'DBIx::Class::Storage::DBI';
(grep { /^DBIx::Class::CDBICompat/ } @modules), # too crufty to touch
'SQL::Translator::Producer::DBIx::Class::File', # ditto
- # not sure how to handle type libraries
- 'DBIx::Class::Storage::DBI::Replicated::Types',
-
# G::L::D is unclean, but we never inherit from it
'DBIx::Class::Admin::Descriptive',
'DBIx::Class::Admin::Usage',