Toru Yamaguchi > DBIx-DBHResolver-0.17 > DBIx::DBHResolver::Strategy::Range

Download:
DBIx-DBHResolver-0.17.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

DBIx::DBHResolver::Strategy::Range - Range based strategy

SYNOPSIS ^

  use DBIx::DBHResolver;
  use DBIx::DBHResolver::Strategy::Range;

  my $day = 24 * 60 * 60;
  my $resolver = DBIx::DBHResolver->new;
  $resolver->config(+{
    clusters => +{
      TIMELINE => +{
        nodes => [qw/TIMELINE_ARCHIVE TIMELINE_YEAR TIMELINE_LATEST/],
        strategy => 'Range',
        strategy_config => [
          TIMELINE_ARCHIVE => [ '>' => 365 ],
          TIMELINE_THIS_YEAR => [ '>' => 30, '<=' => 365 ],
          TIMELINE_LATEST => [ '>=' => 0, '<=' => 30  ],
        ],
      }
    },
    connect_info => +{
      TIMELINE_ARCHIVE => +{ ... },
      TIMELINE_THIS_YEAR => +{ ... },
      TIMELINE_LATEST => +{ ... },
    }
  });

  my $strategy = 'DBIx::DBHResolver::Strategy::List';

  $strategy->connect_info( $resolver, 'TIMELINE', 380 ); # return TIMELINE_ARCHIVE's connect_info
  $strategy->connect_info( $resolver, 'TIMELINE', 55 ); # return TIMELINE_YEAR's connect_info
  $strategy->connect_info( $resolver, 'TIMELINE', 0 ); # return TIMELINE_LATEST's connect_info

DESCRIPTION ^

This module is range based sharding strategy. Supported operator are '>', '>=' '<', '<='.

METHODS ^

connect_info( $resolver, $node_or_cluster, $args )

Return connect_info hash ref.

resolve( $resolver, $node_or_cluster, $key, $args )

Return resolved node_or_cluster name.

AUTHOR ^

Toru Yamaguchi <zigorou@dena.jp<gt>

LICENSE ^

This module is licensed under the same terms as Perl itself.

SEE ALSO ^

syntax highlighting: