Changeset 15557
- Timestamp:
- 07/09/08 13:34:05 (5 years ago)
- Location:
- lang/perl/Mvalve/trunk
- Files:
-
- 2 modified
-
lib/Mvalve.pm (modified) (4 diffs)
-
t/03_extended.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Mvalve/trunk/lib/Mvalve.pm
r15555 r15557 78 78 ); 79 79 80 has 'interval' => (81 is => 'rw',82 isa => 'Int',83 required => 1,84 default => 1085 );86 87 80 has 'timeout' => ( 88 81 is => 'rw', … … 157 150 } 158 151 159 160 152 # otherwise, we need to check if this message is going to be throttled 161 trace( "checking if message to $destination should be throttled" ) if MVALVE_TRACE; 162 my $is_throttled = 163 $self->is_pending( $destination ) || 164 ! $self->try_push( key => $destination ) 165 ; 166 167 if ($is_throttled) { 153 my $is_pending = $self->is_pending( $destination ); 154 my $is_throttled = ! $self->try_push( key => $destination ); 155 trace( "checking if message to $destination should be throttled (pending: $is_pending, throttled: $is_throttled)" ) if MVALVE_TRACE; 156 157 if ($is_throttled || $is_pending) { 168 158 trace( "message", $message->id, "is being throttled") if MVALVE_TRACE; 169 159 $self->defer( $message ); … … 185 175 186 176 my $qs = $self->queue_set; 187 my $interval = $self-> interval;177 my $interval = $self->throttler->{db}->{chain}->{interval}; 188 178 my $table = $qs->choose_table('timed'); 189 179 my $destination = $message->header( DESTINATION_HEADER ); … … 248 238 249 239 sub is_pending { 250 my( $self, $ channel_id) = @_;251 252 my $retry_key = [ $ channel_id, 'retry' ];240 my( $self, $destination ) = @_; 241 242 my $retry_key = [ $destination, 'retry' ]; 253 243 my $count = $self->state_get($retry_key); 254 244 return $count ? 1 : 0; -
lang/perl/Mvalve/trunk/t/03_extended.t
r15551 r15557 16 16 17 17 $ENV{MEMCACHED_SERVERS} ||= '127.0.0.1:11211'; 18 $ENV{MEMCA HCED_NAMESPACE} ||= join('_', __FILE__, $$, {}, rand());18 $ENV{MEMCACHED_NAMESPACE} ||= join('_', __FILE__, $$, {}, rand()); 19 19 $ENV{MEMCACHED_SERVERS} = [ 20 20 split(/\s*,\s*/, $ENV{MEMCACHED_SERVERS}) ]; … … 41 41 module => 'Data::Throttler::Memcached', 42 42 max_items => 1, 43 interval => 10,43 interval => 2, 44 44 cache => { 45 45 data => $ENV{MEMCACHED_SERVERS}, … … 75 75 my $message = $mvalve->next; 76 76 ok( $message, 'first message should not be throttled' ); 77 delete $messages{ $message->id }; 77 if ($message) { 78 delete $messages{ $message->id }; 79 } 78 80 79 81 $count--; … … 89 91 my $i = 0; 90 92 while ($i < $count) { 91 my $rv = $mvalve->next_retry;92 93 my $message = $mvalve->next; 93 94 next unless $rv; 94 next unless $message; 95 95 96 96 ok( delete $messages{ $message->id }, "Deleting a proper (unhandled) message");
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)