-
-
30 Jun 2019 08:19:09 UTC
- Distribution: IO-Lambda
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (562 / 103 / 0)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (90.24KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- LWP
- Net::DNS
- Scalar::Util
- Storable
- Sub::Name
- Time::HiRes
- URI
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
IO::Lambda::DNS - DNS queries lambda style
DESCRIPTION
The module provides access to asynchronous DNS queries through Net::DNS. Two function doing the same operation are featured: constructor
new
and conditiondns
.SYNOPSIS
use strict; use IO::Lambda::DNS qw(:all); use IO::Lambda qw(:all); # simple async query my $reply = IO::Lambda::DNS-> new( "www.site.com" )-> wait; print (($reply =~ /^\d/) ? "Resolved to $reply\n" : "Error: $reply\n"); # parallel async queries lambda { for my $site ( map { "www.$_.com" } qw(google yahoo perl)) { context $site, 'MX', timeout => 0.25; dns { print shift-> string if ref($_[0]) } } }-> wait;
OPTIONS
Accepted options specific to the module are
timeout
ordeadline
(in seconds) andretry
(in times). All other options, such asnameservers
,dnssec
etc etc are passed as is to theNet::DNS::Resolver
constructor. See its man page for details.USAGE
- new
-
Constructor
new
accepts Net::DNS-specific options (see OPTIONS above) and query, and returns a lambda. The lambda accepts no parameters, and returns either an IP address or a response object (depending on the call syntax, see below), or an error string.new ($CLASS, %OPTIONS, $HOSTNAME) :: () -> ($IP_ADDRESS|$ERROR)
In the simple case, accepts
$HOSTNAME
string, and returns also a string, either an IP address or an error. To distinguish between these use/^\d/
regexp, because it is guaranteed that no error message will begin with a digit, and no IP address will begin with anything other than a digit.new (%OPTIONS, ($PACKET | $HOSTNAME, $TYPE)) :: () -> ($RESPONSE|$ERROR)
In the complex case, accepts either
Net::DNS::Packet
object, or$HOSTNAME
and$TYPE
strings, where the latter can be one ofA
,MX
, etc DNS query type. See "bgsend" in Net::DNS::Resolver for the exact syntax.Returns either a
Net::DNS::RR
object or an error string. - dns
-
Condition wrapper over
new
.dns (%OPTIONS, $HOSTNAME) -> $IP_ADDRESS|$ERROR dns (%OPTIONS, ($PACKET | $HOSTNAME $TYPE)) -> $RESPONSE|$ERROR
SEE ALSO
IO::Lambda, Net::DNS::Resolver.
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.
Module Install Instructions
To install IO::Lambda, copy and paste the appropriate command in to your terminal.
cpanm IO::Lambda
perl -MCPAN -e shell install IO::Lambda
For more information on module installation, please visit the detailed CPAN module installation guide.