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