Class: Mongo::Socket::Unix

Inherits:
Mongo::Socket show all
Defined in:
lib/mongo/socket/unix.rb

Overview

Wrapper for Unix sockets.

Since:

  • 2.0.0

Constant Summary

Constants inherited from Mongo::Socket

SSL_ERROR, TIMEOUT_ERROR, TIMEOUT_PACK

Instance Attribute Summary collapse

Attributes inherited from Mongo::Socket

#family, #options, #socket

Instance Method Summary collapse

Methods inherited from Mongo::Socket

#alive?, #close, #connectable?, #eof?, #gets, #read, #readbyte, #write

Constructor Details

#initialize(path, timeout, options = {}) ⇒ Unix

Initializes a new Unix socket.

Examples:

Create the Unix socket.

Unix.new('/path/to.sock', 5)

Parameters:

  • path (String)

    The path.

  • timeout (Float)

    The socket timeout value.

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

    The options.

Options Hash (options):

  • :connect_timeout (Float)

    Connect timeout (unused).

Since:

  • 2.0.0



41
42
43
44
45
# File 'lib/mongo/socket/unix.rb', line 41

def initialize(path, timeout, options = {})
  @path, @timeout, @options = path, timeout, options
  @socket = ::UNIXSocket.new(path)
  set_socket_options(@socket)
end

Instance Attribute Details

#pathString (readonly)

Returns path The path to connect to.

Returns:

  • (String)

    path The path to connect to.

Since:

  • 2.0.0



24
25
26
# File 'lib/mongo/socket/unix.rb', line 24

def path
  @path
end

#timeoutFloat (readonly)

Returns timeout The socket timeout.

Returns:

  • (Float)

    timeout The socket timeout.

Since:

  • 2.0.0



27
28
29
# File 'lib/mongo/socket/unix.rb', line 27

def timeout
  @timeout
end