Enum ns_router::AutoName
[−]
[src]
pub enum AutoName<'a> { Auto(&'a str), HostPort(&'a str, u16), HostDefaultPort(&'a str), Service(&'a str), IpAddr(IpAddr), SocketAddr(SocketAddr), }
A name type that can be read from config
The core idea of AutoName
is that for service with default port 80
(HTTP) we treat names the following way:
example.org
→ A record example.org, port 80example.org:8080
→ A record example.org, port 8080_service._proto.example.org
→ SRV record, and port from the record127.0.0.1
→ IP used directly, port 80127.0.0.1:8080
→ IP/port used directly2001:db8::2:1
→ IPv6 address (note: no brackets)[2001:db8::2:1]:1235
→ IPv6 address and port (note: square brackets)
This works by wrapping the string read from configuration file into
AutoName::Auto
and using it in Router
. You might override things
via configuration specific things, for example in yaml you might want
to write:
addresses:
- !Srv myservice.query.consul
... And convert it into Service("myservice.query.consul")
which will
be resolved using SRV
record (or similar mechanism) instead of
using hostname (i.e. standard expects using _service._proto
prefix but
does not requires that).
Variants
Auto(&'a str)
Auto-determine how to treat the name
HostPort(&'a str, u16)
Resolve host and attach specified port
HostDefaultPort(&'a str)
Resolve host and attach default port to it
Service(&'a str)
Use service name and port resolved using SRV record or similar
IpAddr(IpAddr)
A bare IP used directly as a host
SocketAddr(SocketAddr)
A bare socket address used directly as a service address
Trait Implementations
impl<'a> Debug for AutoName<'a>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more