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

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

Overview

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

常量摘要折叠

VARIABLE_NAME =
'Mongoid.controller_runtime'

类方法摘要折叠

实例方法摘要折叠

类方法详细信息

reset_runtime整数

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

返回:

  • ( Integer )

    上一个运行时值。



92
93
94
95
96
# File 'lib/mongoid/railties/controller_runtime.rb', line 92

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

.runtimeInteger

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

返回:

  • ( Integer )

    运行时值。



76
77
78
# File 'lib/mongoid/railties/controller_runtime.rb', line 76

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

runtime= (value) ⇒整数

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

参数:

  • ( Integer )

    运行时值。

返回:

  • ( Integer )

    运行时值。



85
86
87
# File 'lib/mongoid/railties/controller_runtime.rb', line 85

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

实例方法详细信息

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

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

参数:

  • e ( Mongo::Event::Base )

    监控事件。

返回:

  • ( Integer )

    当前运行时值。



67
68
69
# File 'lib/mongoid/railties/controller_runtime.rb', line 67

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

#开始(_) ⇒ nil

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

返回:

  • ( nil )

    Nil.



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

def 已启动(_) end