class Stockpile::Memory
An in-memory connection manager, providing a complete example of how a Stockpile
connection manager could be made.
Attributes
The primary connection.
Public Class Methods
Create a new Memory
connection manager.
# File lib/stockpile/memory.rb, line 82
Public Instance Methods
Connect unless already connected. Additional client connections can be specified in the parameters as a shorthand for calls to connection_for
.
If narrow?
is true, the same connection will be used for all clients managed by this connection manager.
manager.connect manager.connection_for(:bar) # This means the same as above. manager.connect(:bar)
# File lib/stockpile/memory.rb, line 99
Perform a client connection for a specific client_name
. A client_name
of :all
will always return nil
. If the requested client does not yet exist, the connection will be created.
# File lib/stockpile/memory.rb, line 116
Disconnect for some or all clients. The primary connection will always be disconnected; other clients will be disconnected based on the clients
provided. Only clients actively managed by previous calls to connect
or connection_for
will be disconnected.
If disconnect
is called with the value :all
, all currently managed clients will be disconnected.
If narrow?
is true, the primary connection will be disconnected, which disconnects all connections implicitly.
# File lib/stockpile/memory.rb, line 141
Indicates if this connection manager is using a narrow connection width.
# File lib/stockpile/memory.rb, line 94
Reconnect some or all clients. The primary connection will always be reconnected; other clients will be reconnected based on the clients
provided. Only clients actively managed by previous calls to connect
or connection_for
will be reconnected.
If reconnect
is called with the value :all
, all currently managed clients will be reconnected.
If narrow?
is true, the primary connection will be reconnected, which reconnects all connections implicitly.
# File lib/stockpile/memory.rb, line 125
Private Instance Methods
# File lib/stockpile/memory.rb, line 160 def client_connect(_name = nil, options = {}) return connection if connection && narrow? Data.new(@options.merge(options)) end
# File lib/stockpile/memory.rb, line 169 def client_disconnect(client = connection) client.disconnect if client end
# File lib/stockpile/memory.rb, line 165 def client_reconnect(client = connection) client.reconnect if client end