| 1 | # $Id: /mirror/gungho/lib/Gungho/Component/Throttle/Throttler.pm 3224 2007-10-10T08:08:59.964068Z lestrrat $ | ||
| 2 | # | ||
| 3 | # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp> | ||
| 4 | # All rights reserved. | ||
| 5 | |||
| 6 | package Gungho::Component::Throttle::Throttler; | ||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | use base qw(Gungho::Component::Throttle); | ||
| 10 | |||
| 11 | __PACKAGE__->mk_classdata($_) for qw(throttler); | ||
| 12 | |||
| 13 | sub prepare_throttler | ||
| 14 | { | ||
| 15 | my $self = shift; | ||
| 16 | my %args = @_; | ||
| 17 | |||
| 18 | my $class = delete $args{throttler} || 'Data::Throttler'; | ||
| 19 | if (! Class::Inspector->loaded($class)) { | ||
| 20 | $class->require or die; | ||
| 21 | } | ||
| 22 | |||
| 23 | $args{max_items} ||= 1000; | ||
| 24 | $args{interval} ||= 3600; | ||
| 25 | |||
| 26 | $self->throttler( $class->new( %args ) ); | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |