Class | Moped::Connection |
In: |
lib/moped/connection.rb
lib/moped/connection/socket/tcp.rb lib/moped/connection/socket/connectable.rb lib/moped/connection/socket/ssl.rb lib/moped/connection/manager.rb |
Parent: | Object |
This class contains behaviour of database socket connections.
@since 2.0.0
TIMEOUT | = | 5 |
The default connection timeout, in seconds.
@since 2.0.0 |
|
REPLY_DECODE_STR | = | 'l<5q<l<2' |
host | [R] |
@!attribute host
@return [ String ] The ip address of the host. @!attribute options @return [ Hash ] The connection options. @!attribute port @return [ String ] The port the connection connects on. @!attribute timeout @return [ Integer ] The timeout in seconds. |
options | [R] |
@!attribute host
@return [ String ] The ip address of the host. @!attribute options @return [ Hash ] The connection options. @!attribute port @return [ String ] The port the connection connects on. @!attribute timeout @return [ Integer ] The timeout in seconds. |
port | [R] |
@!attribute host
@return [ String ] The ip address of the host. @!attribute options @return [ Hash ] The connection options. @!attribute port @return [ String ] The port the connection connects on. @!attribute timeout @return [ Integer ] The timeout in seconds. |
timeout | [R] |
@!attribute host
@return [ String ] The ip address of the host. @!attribute options @return [ Hash ] The connection options. @!attribute port @return [ String ] The port the connection connects on. @!attribute timeout @return [ Integer ] The timeout in seconds. |
Initialize the connection.
@example Initialize the connection.
Connection.new("localhost", 27017, 5)
@param [ String ] host The host to connect to. @param [ Integer ] post The server port. @param [ Integer ] timeout The connection timeout. @param [ Hash ] options Options for the connection.
@option options [ Boolean ] :ssl Connect using SSL @since 1.0.0
Connect to the server defined by @host, @port without timeout @timeout.
@example Open the connection
connection.connect
@return [ TCPSocket ] The socket.
@since 1.0.0
Is the connection connected?
@example Is the connection connected?
connection.connected?
@return [ true, false ] If the connection is connected.
@since 1.0.0
Disconnect from the server.
@example Disconnect from the server.
connection.disconnect
@return [ nil ] nil.
@since 1.0.0
Read from the connection.
@example Read from the connection.
connection.read
@return [ Hash ] The returned document.
@since 1.0.0
Get the replies to the database operation.
@example Get the replies.
connection.receive_replies(operations)
@param [ Array<Message> ] operations The query or get more ops.
@return [ Array<Hash> ] The returned deserialized documents.
@since 1.0.0