Net::DNS::Async(3pm)
π Net::DNS::Async(3pm) π
okay bestie, gather round, because this is the manual page for Net::DNS::Async β the Perl module for asynchronous DNS in high volume applications β and it is genuinely iconic. no cap. it's a fire-and-forget DNS helper and it wants you to have a good time. let's get into it π¦
β¨ NAME β¨
Net::DNS::Async β Asynchronous DNS helper for high volume applications π
β¨ SYNOPSIS β¨
like, here's the whole vibe in one go:
use Net::DNS::Async;
my $c = new Net::DNS::Async(QueueSize => 20, Retries => 3);
for (...) {
$c->add(\&callback, @query);
}
$c->await();
sub callback {
my $response = shift;
...
}
slay. that's it. that's the whole flow πΈ
β¨ DESCRIPTION β¨
so. Net::DNS::Async is a fire-and-forget asynchronous DNS helper. what that means in bestie terms: your application drops DNS questions into the helper, and then the callback gets called at some point in the future β without your application having to do literally anything else. no selects. no timeouts. no sitting around waiting for a response. none of that. the module handles all of it, you just vibe π
the combining thing, and why it matters: if you add the same query to the queue more than once, the module may combine the queries β meaning it will perform that query only once, and then call each callback registered for that query in turn, handing the same Net::DNS::Response object to each one.
β οΈ bestie, listen: because of that shared object, you should not modify the Net::DNS::Response object in any way β lest you break things horribly for a subsequent callback. and we mean horribly. like, main-character-of-a-disaster-movie horribly π
this module is similar in principle to POE::Component::Client::DNS, but it does not require POE. so that's a whole dependency you don't have to deal with. obsessed π«Ά
β¨ CONSTRUCTOR β¨
the class method new(...) constructs a new helper object. every single argument is optional (we love a low-pressure situation). these are the parameters recognised as arguments to new():
QueueSizeβ the size of the query queue. if you exceed it, further calls toadd()will block until some responses come in or time out. it's giving backpressure, honestly.Retriesβ how many times to retry a query before giving up. quitting is valid but let's try a few times first πͺTimeoutβ the timeout for an individual query. one query, one clock β°
β¨ METHODS β¨
π« $c->add($callback, @query)
adds a new query for asynchronous handling. the @query arguments are those to Net::DNS::Resolver->bgsend(), q.v. β go read that one, iykyk π
this call will block if the queue is full. when some pending responses are received, or timeout events occur, the call will unblock. so it's not stuck forever, it's just waiting its turn π§
your user callback will be called at some point in the future, with a Net::DNS::Packet object representing the response. and if the query timed out after the specified number of retries? the callback will be called with undef. yes, undef. plan for it π
π« $c->await()
flushes the queue β that is, it waits for and handles all remaining responses. this is the "okay we're done here, wrap it up" button π
β¨ BUGS β¨
the test suite does not test query timeouts. that's it. that's the bug. noted, documented, moving on π
β¨ SEE ALSO β¨
Net::DNSPOE::Component::Client::DNS
β¨ COPYRIGHT β¨
Copyright (c) 2005-2006 Shevek. All rights reserved. π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π this was Net::DNS::Async(3pm) from the User Contributed Perl Documentation section, generated by perl v5.36.0 on 2022-11-19. go forth and send your queries asynchronously, you absolute icon πβ¨π
π¦ where this page comes from
- debian bookworm: libnet-dns-async-perl 1.07-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- debian trixie: libnet-dns-async-perl 1.07-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu noble: libnet-dns-async-perl 1.07-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu resolute: libnet-dns-async-perl 1.07-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu stonking: libnet-dns-async-perl 1.07-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms