class Mongo::Cluster::SocketReaper

A manager that calls a method on each of a cluster's pools to close idle

sockets.

@api private

@since 2.5.0

Public Class Methods

new(cluster) click to toggle source

Initialize the SocketReaper object.

@example Initialize the socket reaper.

SocketReaper.new(cluster)

@param [ Mongo::Cluster ] cluster The cluster whose pools' idle sockets

need to be reaped at regular intervals.

@since 2.5.0

# File lib/mongo/cluster/reapers/socket_reaper.rb, line 36
def initialize(cluster)
  @cluster = cluster
end

Public Instance Methods

execute() click to toggle source

Execute the operation to close the pool's idle sockets.

@example Close the idle sockets in each of the cluster's pools.

socket_reaper.execute

@since 2.5.0

# File lib/mongo/cluster/reapers/socket_reaper.rb, line 46
def execute
  @cluster.servers.each do |server|
    server.pool.close_idle_sockets
  end
  true
end
flush() click to toggle source

When the socket reaper is garbage-collected, there's no need to close

idle sockets; sockets will be closed anyway when the pools are
garbage collected.

@since 2.5.0

# File lib/mongo/cluster/reapers/socket_reaper.rb, line 58
def flush
end