incubator-lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-dev] Improving the ClusterSearcher
Date Tue, 27 Dec 2011 21:31:45 GMT
On Tue, Dec 27, 2011 at 10:15:01PM +0100, Nick Wellnhofer wrote:
> On 27/12/11 21:33, Marvin Humphrey wrote:
>> Ah, I see that you have a process_request() method in the LUCY-205 patch
>> already -- and though it does not take a socket-handle/fileno as an argument,
>> it can be modified easily to do so.
>
> That's an implementaion detail of Net::Server. To use Net::Server, you  
> simply subclass it and implement a process_request method.

You can write a Net::Server::PreFork subclass which has-a
LucyX::Search::SearchServer and implements process_request() like so:

  sub process_request {
      my $self = shift;
      my $client_sock = $self->get_property('client');
      $self->{search_server}->handle_request($client_sock);
  }

>> I think that means that we cannot simply delete SearchServer#serve -- though
>> we can improve on things by making it possible to override serve() or
>> otherwise avoid it.
>
> IMO subclassing SearchServer as it is now wouldn't be the best solution  
> if it's possible at all. 

It's not possible to subclass it in the context of Net::Server, but you can
e.g. write a simple subclass which invokes fork() on each request.

> First, we can't use the SearchServer  
> constructor because we don't want the sockets to be created there. Then,  
> AFAIU classes derived from Lucy::Object::Obj must be inside-out. Is it  
> safe to subclass additional Perl classes like Net::Server that use their  
> own hashref attributes in the traditional way?

No, that won't work.  (But hash-based classes are dangerous to subclass too
because of collisions within the hash's flat namespace.)

> Another solution would be to simply duplicate the SearchServer request  
> handling code in an external module. That's not very elegant but maybe  
> it's the easiest way to go, at least for now.

Isn't that pretty much what we get if we implement handle_request($sock) as a
method on SearchServer?

Marvin Humphrey


Mime
View raw message