类:Mongo::ServerSelector::Primary

继承:
Base
  • 对象
显示全部
定义于:
lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb

Overview

封装在给定候选列表的情况下选择主节点 (primary node in the replica set)服务器的规范。

由于:

  • 2.0.0

常量摘要折叠

SERVER_FORMATTED_NAME =

采用服务器格式的此读取偏好(read preference)的名称。

由于:

  • 2.5.0

'主节点'

实例属性摘要

Base继承的属性

#hedge#max_staleness#options#tag_sets

实例方法摘要折叠

Base继承的方法

#==#candidates#initialize#inspect#local_threshold#local_threshold_with_cluster#select_server#server_selection_timeout#sutable_servers#try_select_server

构造函数详情

该类从Mongo::ServerSelector::Base继承了一个构造函数

实例方法详细信息

#对冲_允许?false

是否允许为此服务器偏好定义对冲选项。

返回:

  • ( false )

    false

由于:

  • 2.0.0



62
63
64
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 62

def 对冲允许?
  false
end

#名称符号

获取服务器模式类型的名称。

例子:

获取此首选项的服务器模式的名称。

preference.name

返回:

由于:

  • 2.0.0



37
38
39
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 37

def 名称
  :primary
end

# secondary_ok?false

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

是否应在传输协议消息上设立secondaryOk 位。即是否可以在从节点(secondary node from replica set)服务器上执行该操作。

返回:

  • ( false )

    false

由于:

  • 2.0.0



46
47
48
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 46

def secondary_ok?
  false
end

#tags_allowed?false

是否允许为此服务器偏好定义标签集。

返回:

  • ( false )

    false

由于:

  • 2.0.0



55
56
57
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 55

def tags_allowed?
  false
end

#to_docHash

将此服务器偏好定义转换为适合发送到MongoDB服务器的格式(即,作为命令字段)。

返回:

  • (哈希)

    服务器偏好格式为命令字段值。

由于:

  • 2.5.0



72
73
74
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 72

def to_doc
  { 模式: SERVER_FORMATTED_NAME }
end

# to_mongos哈希 | nil

将此服务器偏好定义转换为适合发送到 mongos 的值。

如果不应将读取偏好发送到 mongos,则此方法可能会返回 nil。

返回:

  • ( Hash | nil )

    服务器偏好转换为 mongos 命令字段值。

由于:

  • 2.0.0



86
87
88
# File 'lib/ Mongo/server_selector/ 主节点 (primary node in the replica set).rb', line 86

def to_mongos
  nil
end