123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Address::Unix

Relationships & Source Files
Inherits: Object
Defined in: lib/mongo/address/unix.rb

Overview

Sets up socket addresses.

Since:

  • 2.0.0

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(host, port = nil, host_name = nil) ⇒ Unix

Initialize the socket resolver.

Examples:

Initialize the resolver.

Unix.new("/path/to/socket.sock", "/path/to/socket.sock")

Parameters:

  • host (String)

    The host.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/address/unix.rb', line 59

def initialize(host, port=nil, host_name=nil)
  @host = host
end

Class Method Details

.parse(address) ⇒ Array<String>

Parse a socket path.

Examples:

Parse the address.

Unix.parse("/path/to/socket.sock")

Parameters:

  • address (String)

    The address to parse.

Returns:

  • (Array<String>)

    A list with the host (socket path).

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/address/unix.rb', line 47

def self.parse(address)
  [ address ]
end

Instance Attribute Details

#hostString (readonly)

Returns:

  • (String)

    host The host.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/address/unix.rb', line 27

attr_reader :host

#portnil (readonly)

Returns:

  • (nil)

    port Will always be nil.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/address/unix.rb', line 30

attr_reader :port

Instance Method Details

#socket(socket_timeout, options = {}) ⇒ Mongo::Socket::Unix

This method is for internal use only.

Get a socket for the provided address type, given the options.

Examples:

Get a Unix socket.

address.socket(5)

Parameters:

  • socket_timeout (Float)

    The socket timeout.

  • options (Hash) (defaults to: {})

    The options.

Options Hash (options):

  • :connect_timeout (Float)

    Connect timeout.

Returns:

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/address/unix.rb', line 77

def socket(socket_timeout, options = {})
  Socket::Unix.new(host, socket_timeout, options)
end