类:Mongo::Cluster::PeriodicExecutor Private

继承:
对象
  • 对象
显示全部
包括:
背景线程
定义于:
lib/ Mongo/ 集群/ periodic_executor.rb

Overview

此类是私有 API 的一部分。 应尽可能避免使用此类,因为它将来可能会被删除或更改。

定期在其执行程序上调用 #execute 的管理器。

由于:

  • 2.5.0

常量摘要折叠

FREQUENCY =

此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。

定期执行器执行的默认时间间隔。

由于:

  • 2.5.0

5

Loggable中包含的常量

Loggable::PREFIX

实例属性摘要折叠

实例方法摘要折叠

包含在BackgroundThread中的方法

#run! , #running?#stop!

Loggable中包含的方法

#log_debug#log_error#log_ Fatal#log_info#log_warn#logger

构造函数详情

#initialize (executors, options = {}) "> PerioticExecutor

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

创建定期执行程序。

例子:

创建一个 periodicexecutor。

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

参数:

  • executors ( Array<Object> )

    执行者。 每个都必须响应 #execute 和 #flush。

  • 选项 哈希 (默认为: {}

    选项。

选项哈希 ( options ):

  • :logger 记录器

    要使用的自定义记录器。

由于:

  • 2.5.0



47
48
49
50
51
52
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 47

def 初始化(executors, 选项 = {})
  @thread = nil
  @executors = executors
  @stop_semaphore = 信号量.new
  @options = 选项
end

实例属性详细信息

# options对象(只读)

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

由于:

  • 2.5.0



54
55
56
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 54

def 选项
  @options
end

实例方法详细信息

# do_work对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

由于:

  • 2.5.0



58
59
60
61
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 58

def do_work
  执行
  @stop_semaphore.wait(FREQUENCY)
end

#执行对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

在每个收割机上trigger执行调用。

例子:

trigger所有收割者。

periodic_executor.execute

由于:

  • 2.5.0



86
87
88
89
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 86

def 执行
  @executors.(:execute)
  true
end

# flush对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

执行所有待处理的操作。

例子:

执行所有待处理的操作。

periodic_executor.flush

由于:

  • 2.5.0



99
100
101
102
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 99

def 刷新
  @executors.(:flush)
  true
end

# pre_stop对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

由于:

  • 2.5.0



63
64
65
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 63

def pre_stop
  @stop_semaphore.信号
end

# stop (final = false) ⇒对象

此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。

由于:

  • 2.5.0



67
68
69
70
71
72
73
74
75
76
# File 'lib/ Mongo/ 集群/ periodic_executor.rb', line 67

def 请停止(final = false)
  

  开始
    刷新
  救援
  end

  true
end