Class: Mongo::Cluster::PeriodicExecutor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/cluster/periodic_executor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A manager that calls #execute on its executors at a regular interval.

Since:

  • 2.5.0

Constant Summary

FREQUENCY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The default time interval for the periodic executor to execute.

Since:

  • 2.5.0

5

Instance Method Summary collapse

Constructor Details

#initialize(*executors) ⇒ PeriodicExecutor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a periodic executor.

Examples:

Create a PeriodicExecutor.

Mongo::Cluster::PeriodicExecutor.new(reaper, reaper2)

Since:

  • 2.5.0



39
40
41
42
# File 'lib/mongo/cluster/periodic_executor.rb', line 39

def initialize(*executors)
  @thread = nil
  @executors = executors
end

Instance Method Details

#executeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Trigger an execute call on each reaper.

Examples:

Trigger all reapers.

periodic_executor.execute

Since:

  • 2.5.0



78
79
80
# File 'lib/mongo/cluster/periodic_executor.rb', line 78

def execute
  @executors.each(&:execute) and true
end

#flushObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Execute all pending operations.

Examples:

Execute all pending operations.

periodic_executor.flush

Since:

  • 2.5.0



90
91
92
# File 'lib/mongo/cluster/periodic_executor.rb', line 90

def flush
  @executors.each(&:flush) and true
end

#run!Object Also known as: restart!

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Start the thread.

Examples:

Start the periodic executor's thread.

periodic_executor.run!

Since:

  • 2.5.0



52
53
54
# File 'lib/mongo/cluster/periodic_executor.rb', line 52

def run!
  @thread && @thread.alive? ? @thread : start!
end

#stop!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Stop the executor's thread.

Examples:

Stop the executors's thread.

periodic_executor.stop!

Since:

  • 2.5.0



65
66
67
68
# File 'lib/mongo/cluster/periodic_executor.rb', line 65

def stop!
  begin; flush; rescue; end
  @thread.kill && @thread.stop?
end