Permalink
Browse files

Sub::Retryの翻訳を追加しました

  • Loading branch information...
1 parent 1e7211e commit 46b2dda98a7f3d4ce232bde5a5aac9d6653fb291 @syohex syohex committed Oct 17, 2011
Showing with 98 additions and 0 deletions.
  1. +98 −0 docs/modules/Sub-Retry-0.04/Retry.pod
@@ -0,0 +1,98 @@
+=encoding utf-8
+
+=head1 NAME
+
+=begin original
+
+Sub::Retry - retry $n times
+
+=end original
+
+Sub::Retry - $n回繰り返す
+
+=head1 SYNOPSIS
+
+ use Sub::Retry;
+ use LWP::UserAgent;
+
+ my $ua = LWP::UserAgent->new();
+ my $res = retry 3, 1, sub {
+ $ua->post('http://example.com/api/foo/bar');
+ };
+
+=head1 DESCRIPTION
+
+=begin original
+
+Sub::Retry provides the function named 'retry'.
+
+=end original
+
+Sub::Retryは 'retry'関数を提供します.
+
+=head1 FUNCTIONS
+
+=begin original
+
+=over 4
+
+=item retry($n_times, $delay, \&code [, \&retry_if])
+
+This function calls C<< \&code >>. If the code throws exception, this function retry C<< $n_times >> after C<< $delay >> seconds.
+
+Return value of this function is the return value of C<< \&code >>. This function cares L<wantarray>.
+
+You can also customize the retry condition. In that case C<< \&retry_if >> specify coderef. The coderef arguments is return value the same. (Default: retry condition is throws exception)
+
+ use Sub::Retry;
+ use Cache::Memcached::Fast;
+
+ my $cache = Cache::Memcached::Fast->new(...);
+ my $res = retry 3, 1, sub {
+ $cache->get('foo');
+ } sub {
+ my $res = shift;
+ defined $res ? 0 : 1;
+ };
+
+=back
+
+=end original
+
+=over 4
+
+=item retry($n_times, $delay, \&code [, \&retry_if])
+
+C<< \&code >>を呼び出します. もし例外が投げられた場合, C<< $delay >>秒後ごとに
+C<< $n_times >>回リトライします.
+
+この関数の戻り値は C<< \&code >>の戻り値となります. L<wantarray>は考慮されます.
+
+リトライの条件をカスタマイズすることが可能で, C<< \&retry_if >>コードリファレンスを使います.
+コードリファレンスの引数は, 戻り値と同じです. (デフォルトでは例外が投げられたときにリトライします).
+
+ use Sub::Retry;
+ use Cache::Memcached::Fast;
+
+ my $cache = Cache::Memcached::Fast->new(...);
+ my $res = retry 3, 1, sub {
+ $cache->get('foo');
+ } sub {
+ my $res = shift;
+ defined $res ? 0 : 1;
+ };
+
+=back
+
+=head1 AUTHOR
+
+Tokuhiro Matsuno E<lt>tokuhirom AAJKLFJEF GMAIL COME<gt>
+
+=head1 LICENSE
+
+Copyright (C) Tokuhiro Matsuno
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut

0 comments on commit 46b2dda

Please sign in to comment.