Patch: Selector Additions

Brad Fitzpatrick brad at danga.com
Sun Dec 17 17:49:02 UTC 2006


Rather than having the selector_creator stuff, can you just register a
classname, so this code:

    if ($self->{'role'} eq "web_server") {
        Perlbal::ClientHTTP->new_from_base($cb);
        return;
    } elsif ($self->{'role'} eq "reverse_proxy") {
        Perlbal::ClientProxy->new_from_base($cb);
        return;
    } else {
        $cb->_simple_response(500, "Can't map to service type $self->{'role'}");
    }

Could just be something like:

   my $sub_class = sub_class_of($self->{role});
   if ($sub_class) {
      $sub_class->new_from_base($cb);
      return;
    } else {
        $cb->_simple_response(500, "Can't map to service type $self->{'role'}");
    }

And then sub_class_of looks at the registered role->class?

Would simplify it a bit.

But I'm more interested in this XMPP stuff you're doing ... care to share?  :)



On Sat, 16 Dec 2006, Matt Mankins wrote:

> Hi.
>
> We were having an issue where we wanted to use a selector with a
> service whose role was not one of "web_server" or "reverse_proxy".
> Attached is the patch (against 1.47) we use to let this happen,
> rather than giving a 500 server error.
>
> Now in the load() of your Plugin:
>
>   Perlbal::Service::add_role(
> 							'xmpp_binder',
>
> \&Perlbal::Plugin::XMPP_Binder::Client::new,
> ->
> \&Perlbal::Plugin::XMPP_Binder::Client::new_from_base
> 						);
>
> Let us know if there was a better way to do this and we'll do it that
> way.
>
> Best,
> Matt Mankins
> Lorem Ipsum Books
> http://www.SaveTheBookstoreSaveTheWorld.com/
>
>
>


More information about the perlbal mailing list