| 1 | package Magpie::Transformer::ServiceUnavailable; | ||
| 2 | $Magpie::Transformer::ServiceUnavailable::VERSION = '1.141660'; | ||
| 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 | |||
| 43 | =pod | ||
| 44 | |||
| 45 | =head1 NAME | ||
| 46 | |||
| 47 | Magpie::Transformer::ServiceUnavailable - Use Plack Middleware Handlers As Pipeline Components | ||
| 48 | |||
| 49 | =head1 VERSION | ||
| 50 | |||
| 51 | version 1.141660 | ||
| 52 | |||
| 53 | =head1 AUTHORS | ||
| 54 | |||
| 55 | =over 4 | ||
| 56 | |||
| 57 | =item * | ||
| 58 | |||
| 59 | Kip Hampton <kip.hampton@tamarou.com> | ||
| 60 | |||
| 61 | =item * | ||
| 62 | |||
| 63 | Chris Prather <chris.prather@tamarou.com> | ||
| 64 | |||
| 65 | =back | ||
| 66 | |||
| 67 | =head1 COPYRIGHT AND LICENSE | ||
| 68 | |||
| 69 | This software is copyright (c) 2011 by Tamarou, LLC. | ||
| 70 | |||
| 71 | This is free software; you can redistribute it and/or modify it under | ||
| 72 | the same terms as the Perl 5 programming language system itself. | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | |||
| 77 | __END__ | ||
| 78 | |||
| 79 | # SEEALSO: Magpie |