Module: Bones::RPC::ReadPreference

Extended by:
ReadPreference
Included in:
ReadPreference
Defined in:
lib/bones/rpc/read_preference.rb,
lib/bones/rpc/read_preference/nearest.rb,
lib/bones/rpc/read_preference/selectable.rb

Overview

Provides behaviour around getting various read preference implementations.

Since:

  • 2.0.0

Defined Under Namespace

Modules: Selectable Classes: Nearest

Constant Summary collapse

PREFERENCES =

Hash lookup for the read preference classes based off the symbols provided in configuration.

Since:

  • 2.0.0

{
  nearest: Nearest
}.freeze

Instance Method Summary collapse

Instance Method Details

#get(name, tags = nil) ⇒ Object

Get a read preference for the provided name. Valid names are:

- :nearest
- :primary
- :primary_preferred
- :secondary
- :secondary_preferred

Examples:

Get the primary read preference.

Bones::RPC::ReadPreference.get(:primary)

Parameters:

  • name (Symbol)

    The name of the preference.

  • tags (Array<Hash>) (defaults to: nil)

    The tag sets to match the node on.

Returns:

  • (Object)

    The appropriate read preference.

Since:

  • 2.0.0



38
39
40
# File 'lib/bones/rpc/read_preference.rb', line 38

def get(name, tags = nil)
  PREFERENCES.fetch(name.to_sym).new(tags)
end