| Class | Mongo::Address |
| In: |
lib/mongo/address/ipv6.rb
lib/mongo/address/ipv4.rb lib/mongo/address/unix.rb lib/mongo/address.rb |
| Parent: | Object |
Represents an address to a server, either with an IP address or socket path.
@since 2.0.0
| FAMILY_MAP | = | { ::Socket::PF_UNIX => Unix, ::Socket::AF_INET6 => IPv6, ::Socket::AF_INET => IPv4 |
Mapping from socket family to resolver
class.
@since 2.0.0 |
|
| LOCALHOST | = | 'localhost'.freeze |
The localhost constant.
@since 2.1.0 |
| host | [R] | @return [ String ] host The original host name. |
| port | [R] | @return [ Integer ] port The port. |
| seed | [R] | @return [ String ] seed The seed address. |
Initialize the address.
@example Initialize the address with a DNS entry and port.
Mongo::Address.new("app.example.com:27017")
@example Initialize the address with a DNS entry and no port.
Mongo::Address.new("app.example.com")
@example Initialize the address with an IPV4 address and port.
Mongo::Address.new("127.0.0.1:27017")
@example Initialize the address with an IPV4 address and no port.
Mongo::Address.new("127.0.0.1")
@example Initialize the address with an IPV6 address and port.
Mongo::Address.new("[::1]:27017")
@example Initialize the address with an IPV6 address and no port.
Mongo::Address.new("[::1]")
@example Initialize the address with a unix socket.
Mongo::Address.new("/path/to/socket.sock")
@param [ String ] seed The provided address. @param [ Hash ] options The address options.
@since 2.0.0
Check equality of the address to another.
@example Check address equality.
address == other
@param [ Object ] other The other object.
@return [ true, false ] If the objects are equal.
@since 2.0.0
Check equality for hashing.
@example Check hashing equality.
address.eql?(other)
@param [ Object ] other The other object.
@return [ true, false ] If the objects are equal.
@since 2.2.0
Get a pretty printed address inspection.
@example Get the address inspection.
address.inspect
@return [ String ] The nice inspection string.
@since 2.0.0
Get a socket for the provided address, given the options.
The address the socket connects to is determined by the algorithm described in the intialize_resolver! documentation. Each time this method is called, initialize_resolver! will be called, meaning that a new hostname lookup will occur. This is done so that any changes to which addresses the hostname resolves to will be picked up even if a socket has been connected to it before.
@example Get a socket.
address.socket(5, :ssl => true)
@param [ Float ] socket_timeout The socket timeout. @param [ Hash ] ssl_options SSL options. @param [ Hash ] options The options.
@option options [ Float ] :connect_timeout Connect timeout.
@return [ Mongo::Socket::SSL, Mongo::Socket::TCP, Mongo::Socket::Unix ] The socket.
@since 2.0.0