Perlbal and Rails

Brad Fitzpatrick brad at danga.com
Mon Mar 5 21:16:22 UTC 2007


If somebody could write this plugin, I'd love to include it by default, as
I think it's something a lot of people want....

- Brad


On Wed, 21 Feb 2007, Cal Henderson wrote:

> Philip Murray <pmurray at nevada.net.nz> wrote:
> : Basically, if the file exists locally serve it. If it doesn't exist
> : locally, proxy it to one of the backends.
> :
> : In a sense this is kind of combining the web_server role with the
> : reverse_proxy role, is it curently possible to do this with Perlbal?
>
>
> you can fairly easily do this by adding a hook to a web server backend
> (via a custom plugin) to check for 404's (the hook is called
> static_get_poststat_file_missing) and then move the request over to a
> proxy backend.
>
> something like (untested):
>
> ------------------------------------------------------------------
>
> package Perlbal::Plugin::Thinger;
>
> use strict;
> use warnings;
>
> sub register {
>  my ($class, $svc) = @_;
>
>  $svc->register_hook('MyHook', 'static_get_poststat_file_missing', sub
> {
>
>   my ($cb) = @_;
>
>   my $new_svc = Perlbal->service('my_proxy_service');
>
>   $new_svc->adopt_base_client($cb);
>
>   return 1;
>  });
>
>  return 1;
> }
>
>
> sub unregister {
>  my ($class, $svc) = @_;
>
>  $svc->unregister_hooks('MyHook');
>
>  return 1;
> }
>
> ------------------------------------------------------------------
>
>
> --cal
>
>


More information about the perlbal mailing list