Continuing my quest to get a nice object-oriented interface to search domains.
Thanks very much to everyone who replied to my question about interesting
error messages - I tried to thank you on the original thread but the server
timed out. Anyway, I decided to go for "return 1 for success, 0 for failure
plus set an object property {error} if there's an error message". But now
something else is making me rethink.
Some people want to search for 100 domains at a time. Now doing this normally
requires waiting, serially, for 100 responses from WHOIS servers around the
world. Obviously this can take forever, and meanwhile the server times out or
whatever. So the actual call to WHOIS is a good candidate for multiprocessing:
for (@domains) { if (fork()) {...}}
Now I am new to this, as to OO, and I don't know that the concepts mix that
well. I would like to fork little processes to do the whois, and return the
results as a fully-fledged object. But processes don't share memory, so I
can't do that (right?) So I guess, again, I have some alternatives....:
- Rearchitect my application. Instead of having Domain->whois(),
have ListOfDomains->whois(), and do multiprocessing within that. Not
beautiful. Why should a simple array of objects turn into an object of its own?
- Within the multiprocessing, create a little copy of the domain object, and
do the whois method. Then return a string which is parsed by the main script
and used as the result. Also ugly, because it creates 2 copies of each domain
searched, and because it means shifting some of the whois operation (like
parsing the result) off the module and on to the frontend. Boo.
- Somehow make the Domain->whois() method fork() and make the frontend
wait for the results. Not as ugly as the last method, but still shifts work on
to the frontend.
- Create a DomainList object which interacts with the Domain object, and has
a whois method which forks lots of little Domain->whois() methods and waits
for the results. Get rid of the global error variable and just have a string
result returned from the Domain->whois() method, which is then parsed by
the DomainList. Neat... but how much overhead will all this object creation
have? Speed is of the essence.
Once again, none of the solutions seem perfect. And no, I can't use Thread;
because this module is for distribution. So anyone who knows how to do good OO
IPC could help a lot by enlightening me.
Cheers, Dave.