[Catalyst] DNS as a Catalyst Model

Leo Cacciari leo.cacciari at gmail.com
Wed Jun 6 14:54:42 GMT 2007

I'm planing to develop a Catalyst::Model::DNS, allowing Catalyst
applications to access (and update through dynamic queries) a Domain
Name Service.

Obviously, the first concern is to not reinvent the wheel. I'm unable to
find such a module on CPAN, so  it does not seems to exist. However,
someone could be working on it out there... If so, please let me know!

Now come the questions. First, I'm thinking to use Net::DNS
(http://search.cpan.org/~olaf/Net-DNS-0.59/lib/Net/DNS.pm and
http://www.net-dns.org/) as an underlying module, wrapping it in a
subclass of Catalyst::Module, having the wrapper performing
Catalyst-related tasks, e.g. using the Catalyst configuration mechanism
instead of the one included in Net::DNS. Is this the right approach?
Should I use Net::DNS (which I know for already having used it) or there
are other DNS modules better suited for using in a Catalyst model? (see
also the second question below).

My second question is more generic, but I'll frame it in the context of
this mail nevertheless. DNS queries can be time-consuming, thus to avoid
blocking the application while waiting for the answer, Net::DNS allows
"background queries" (see
http://search.cpan.org/~olaf/Net-DNS-0.59/lib/Net/DNS.pm#Perform_a_background_query_and_do_some_other_work_while_waiting_for_the_answer.) How could I make this behaviour accessible to Catalyst controllers/views? What I was thinking was something along the following lines (where generate_unique_identifier does what it says;)):

sub submit_request {
  my $self = shift;
  my $socket = $self->resolver->bgsend(@_);
  my $id = generate_unique_identifier();
  $self->{pending}->{$id} = $socket;
  return $id;

sub retrive_answer {
   my $self = shift;
   my ($id) = @_;
   $socket = $self->{pending}->{$id};
   return undef unless $self->resolver->bgisready($socket);
   delete $self->{pending}->{$id};
   return $self->resolver->bgread($socket);

I use an indirection, returning an identifier, for two reasons: first,
this ensure that the socket reading will be done by the model. Second,
this should be easier to integrate in a cache mechanism, which I plan
adding to the model.

Leo Cacciari
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
	firmata digitalmente
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070606/2f8539b5/attachment.pgp

More information about the Catalyst mailing list