| 1 | package Magpie::Transformer::ServiceUnavailable; | ||
| 2 | $Magpie::Transformer::ServiceUnavailable::VERSION = '1.163200'; | ||
| 3 | use Moose; | ||
| 4 | |||
| 5 | # ABSTRACT: Use Plack Middleware Handlers As Pipeline Components | ||
| 6 | |||
| 7 | use Magpie::Constants; | ||
| 8 | use Plack::Response; | ||
| 9 | use Plack::Request; | ||
| 10 | |||
| 11 | extends 'Magpie::Transformer'; | ||
| 12 | |||
| 13 | __PACKAGE__->register_events( (qw(available)) ); | ||
| 14 | |||
| 15 | sub load_queue { return (qw( available )) } | ||
| 16 | |||
| 17 | has message => ( | ||
| 18 | isa => 'Str', | ||
| 19 | is => 'ro', | ||
| 20 | default => 'We are working as hard as we can already.' | ||
| 21 | ); | ||
| 22 | |||
| 23 | has retry_after => ( isa => 'Str', is => 'ro', ); | ||
| 24 | |||
| 25 | sub available { | ||
| 26 | my ( $self, $ctxt ) = @_; | ||
| 27 | my $HTTP_503 = HTTP::Throwable::Factory->new_exception( | ||
| 28 | { status_code => 503, | ||
| 29 | retry_after => $self->retry_after, | ||
| 30 | message => $self->message, | ||
| 31 | } | ||
| 32 | ); | ||
| 33 | my $r = $mw->call( $self->request->env ); | ||
| 34 | my $new_resp = Plack::Response->new(@$r); | ||
| 35 | $self->plack_response($new_resp); | ||
| 36 | $self->plack_request( Plack::Request->new($env) ); | ||
| 37 | return DONE; | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | =pod | ||
| 43 | |||
| 44 | =encoding UTF-8 | ||
| 45 | |||
| 46 | =head1 NAME | ||
| 47 | |||
| 48 | Magpie::Transformer::ServiceUnavailable - Use Plack Middleware Handlers As Pipeline Components | ||
| 49 | |||
| 50 | =head1 VERSION | ||
| 51 | |||
| 52 | version 1.163200 | ||
| 53 | |||
| 54 | =head1 AUTHORS | ||
| 55 | |||
| 56 | =over 4 | ||
| 57 | |||
| 58 | =item * | ||
| 59 | |||
| 60 | Kip Hampton <kip.hampton@tamarou.com> | ||
| 61 | |||
| 62 | =item * | ||
| 63 | |||
| 64 | Chris Prather <chris.prather@tamarou.com> | ||
| 65 | |||
| 66 | =back | ||
| 67 | |||
| 68 | =head1 COPYRIGHT AND LICENSE | ||
| 69 | |||
| 70 | This software is copyright (c) 2011 by Tamarou, LLC. | ||
| 71 | |||
| 72 | This is free software; you can redistribute it and/or modify it under | ||
| 73 | the same terms as the Perl 5 programming language system itself. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | __END__ |