DBIx::DBHResolver::Strategy::List - write short description for DBIx::DBHResolver::Strategy::List
use DBIx::DBHResolver; use DBIx::DBHResolver::Strategy::List; our %BLOOD_TYPES = ( UNKNOWN => 0, A => 1, B => 2, O => 3, AB => 4, ); my $resolver = DBIx::DBHResolver->new; $resolver->config(+{ clusters => +{ BLOOD => +{ node => [ qw/BLOOD_A BLOOD_B BLOOD_O BLOOD_AB_OR_UNKNOWN/ ], strategy => 'List', strategy_config => +{ BLOOD_A => [qw/1/], BLOOD_B => [qw/2/], BLOOD_O => [qw/3/], BLOOD_AB_OR_UNKNOWN => [qw/0 4/] }, } }, connect_info => +{ BLOOD_A => +{ ... }, BLOOD_B => +{ ... }, BLOOD_O => +{ ... }, BLOOD_AB_OR_UNKNOWN => +{ ... }, }, }); my $strategy = 'DBIx::DBHResolver::Strategy::List'; $strategy->connect_info( $resolver, 'BLOOD', $BLOOD_TYPE{A} ); # return BLOOD_A's connect_info $strategy->connect_info( $resolver, 'BLOOD', $BLOOD_TYPE{B} ); # return BLOOD_B's connect_info $strategy->connect_info( $resolver, 'BLOOD', $BLOOD_TYPE{O} ); # return BLOOD_O's connect_info $strategy->connect_info( $resolver, 'BLOOD', $BLOOD_TYPE{AB} ); # return BLOOD_AB_OR_UNKNOWN's connect_info $strategy->connect_info( $resolver, 'BLOOD', $BLOOD_TYPE{UNKNOWN} ); # return BLOOD_AB_OR_UNKNOWN's connect_info
This module is list based sharding strategy.
Return connect_info hash ref.
Return resolved node_or_cluster name.
Toru Yamaguchi <zigorou@dena.jp<gt>
This module is licensed under the same terms as Perl itself.
To install DBIx::DBHResolver, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::DBHResolver
CPAN shell
perl -MCPAN -e shell install DBIx::DBHResolver
For more information on module installation, please visit the detailed CPAN module installation guide.