Myriad
view release on metacpan or search on metacpan
bin/myriad-migrate-rpc-streams.pl view on Meta::CPAN
unless ( await $redis->exists($old_rpc_stream) ) {
$log->fatalf('Cannot find old rpc stream for service %s', $service_name);
exit 1;
}
try {
await $redis->xgroup('CREATE', $old_rpc_stream, 'rpc_migration', 0);
} catch ($e) {
if ($e =~ /BUSYGROUP/) {
$log->fatalf('Got a busygroup for stream %s are you running another migration?', $old_rpc_stream);
} else {
$log->fatalf('Failed to create group for stream %s - %s', $old_rpc_stream, $e);
}
exit 1;
}
try {
while (my ($batch) = await $redis->xreadgroup(
GROUP => 'rpc_migration', 'migrator',
COUNT => 50,
lib/Myriad/Transport/Redis.pm view on Meta::CPAN
=cut
async method stream_length ($stream) {
return await $redis->xlen($self->apply_prefix($stream));
}
=head2 borrow_instance_from_pool
Returns a Redis connection either from a pool of connection or a new one.
With the possibility of waiting to get one, if all connection were busy and we maxed out our limit.
=cut
async method borrow_instance_from_pool {
$log->tracef('Available Redis pool count: %d', 0 + $redis_pool->@*);
if (my $available_redis = shift $redis_pool->@*) {
++$pending_redis_count;
return $available_redis;
} elsif ($pending_redis_count < $max_pool_count) {
++$pending_redis_count;
lib/Myriad/Transport/Redis.pod view on Meta::CPAN
=back
=head2 stream_length
Return the length of a given stream
=head2 borrow_instance_from_pool
Returns a Redis connection either from a pool of connection or a new one.
With the possibility of waiting to get one, if all connection were busy and we maxed out our limit.
=head2 return_instance_to_pool
This puts back a redis connection into Redis pool, so it can be used by other called.
It should be called at the end of every usage, as on_ready.
It should also be possible with a try/finally combination..
but that's currently failing with the $redis_pool slot not being defined.
Takes the following parameters:
( run in 0.240 second using v1.01-cache-2.11-cpan-87723dcf8b7 )