| 1 | package PawsX::Waiter; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use PawsX::Waiter::Client; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | our $VERSION = "0.03"; | |||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | sub GetWaiter { | ||||||||
|
Subroutine
GetWaiter: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 14 | 3 | my ( $self, $waiter ) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 3 | my $version = $self->version; | |||||||||
| 17 | 3 | my $waiter_file = path(__FILE__)->parent->child('Waiter/waiters.json'); | |||||||||
| 18 | |||||||||||
| 19 | 3 | my $service = lc $self->service; | |||||||||
| 20 | 3 | my $definition = $waiter_file->slurp(); | |||||||||
| 21 | 3 | my $waiter_struct = JSON->new->utf8(1)->decode($definition); | |||||||||
| 22 | |||||||||||
| 23 | 3 | ▶ | if ( my $config = $waiter_struct->{$service}->{$version}->{$waiter} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | return PawsX::Waiter::Client->new( | ||||||||||
| 25 | client => $self, | ||||||||||
| 26 | delay => $config->{'delay'}, | ||||||||||
| 27 | maxAttempts => $config->{'maxAttempts'}, | ||||||||||
| 28 | operation => $config->{'operation'}, | ||||||||||
| 29 | 3 | acceptors => $config->{'acceptors'}, | |||||||||
| 30 | ); | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | die "Invalid waiter: " . $waiter; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 2 | 1; | |||||||||
| 37 | __END__ | ||||||||||