Documentation ¶
Overview ¶
Package srvcache provides a caching SRV lookup service that creates a short term cache of SRV answers - it does not comply with DNS protocols like the timings set by DNS servers, its more a short term - think 5 seconds - buffer to avoid hitting the dns servers repeatedly
Index ¶
- type BasicServer
- func (s *BasicServer) Host() string
- func (s *BasicServer) HostPort() string
- func (s *BasicServer) Port() uint16
- func (s *BasicServer) Scheme() string
- func (s *BasicServer) SetHost(host string)
- func (s *BasicServer) SetPort(port int)
- func (s *BasicServer) SetScheme(scheme string)
- func (s *BasicServer) String() string
- func (s *BasicServer) URL() (u *url.URL, err error)
- type Cache
- type Resolver
- type Server
- type Servers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicServer ¶
type BasicServer struct {
// contains filtered or unexported fields
}
BasicServer is a representation of a network server host and port, implements Server
func (*BasicServer) Host ¶
func (s *BasicServer) Host() string
Host retrieves the host for the server
func (*BasicServer) HostPort ¶
func (s *BasicServer) HostPort() string
HostPort is a string in hostname:port format
func (*BasicServer) Port ¶
func (s *BasicServer) Port() uint16
Port retrieves the port for the server
func (*BasicServer) SetHost ¶
func (s *BasicServer) SetHost(host string)
SetHost sets the host for the server
func (*BasicServer) SetPort ¶
func (s *BasicServer) SetPort(port int)
SetPort sets the port for the server
func (*BasicServer) SetScheme ¶
func (s *BasicServer) SetScheme(scheme string)
SetScheme sets the url scheme
func (*BasicServer) String ¶
func (s *BasicServer) String() string
String is a string representation of the server in url format
type Cache ¶
Cache provides a fixed term DNS cache for SRV lookups
type Resolver ¶
type Resolver func(service string, proto string, name string) (cname string, addrs []*net.SRV, err error)
Resolver performs dns lookup like net.LookupSRV
type Server ¶
type Server interface { Host() string SetHost(string) Port() uint16 SetPort(int) Scheme() string SetScheme(string) String() string URL() (u *url.URL, err error) HostPort() string }
Server is a Server that can be stored in the collection
type Servers ¶
type Servers interface { Count() int Strings() (urls []string) URLs() (urls []*url.URL, err error) HostPorts() (hps []string) Servers() []Server Each(func(Server)) }
Servers is a collection of server urls
func StringHostsToServers ¶
StringHostsToServers converts an array of servers like host:123 into an array of Servers collection
if an empty scheme is given the string will be parsed by a url parser and the embedded scheme will be used, if that does not parse into a valid url then an error will be returned