类:Mongoid::Railties::ControllerRuntime::Collector

继承:
对象
  • 对象
显示全部
定义于:
lib/mongoid/railties/controller_runtime.rb

Overview

订阅MongoDB mongo驾驶员命令监控的 运行时指标收集器。将该值存储在线程局部变量中,以便在应用程序从背景线程发出MongoDB操作时提供正确的计数。

常量摘要折叠

VARIABLE_NAME =
" Mongoid.controller_runtime ".冻结

类方法摘要折叠

实例方法摘要折叠

类方法详细信息

reset_runtime整数

将当前线程的运行时值重置为零。

返回:

  • ( Integer )

    上一个运行时值。



96
97
98
99
100
# File 'lib/mongoid/railties/controller_runtime.rb', line 96

def self.reset_runtime
  to_now = 运行时
  self.运行时 = 0
  to_now
end

.runtimeInteger

获取当前线程的运行时值。

返回:

  • ( Integer )

    运行时值。



80
81
82
# File 'lib/mongoid/railties/controller_runtime.rb', line 80

def self.运行时
  线程化.获取(VARIABLE_NAME) { 0 }
end

runtime= (value) ⇒整数

在当前线程上设置运行时值。

参数:

  • ( Integer )

    运行时值。

返回:

  • ( Integer )

    运行时值。



89
90
91
# File 'lib/mongoid/railties/controller_runtime.rb', line 89

def self.运行时= 
  线程化.(VARIABLE_NAME, )
end

实例方法详细信息

# _completed (e) ⇒ Integer也称为:成功失败

事件完成时调用。 更新运行时值。

参数:

  • e ( Mongo::Event::Base )

    监控事件。

返回:

  • ( Integer )

    当前运行时值。



71
72
73
# File 'lib/mongoid/railties/controller_runtime.rb', line 71

def _completed e
  收集器.运行时 += e.duration * 1000
end

#开始(_) ⇒ nil

事件开始时调用。 不执行任何操作。

返回:

  • ( nil )

    Nil.



64
# File 'lib/mongoid/railties/controller_runtime.rb', line 64

def 已启动 _ end