Class: Moped::ReadPreference::SecondaryPreferred
- Inherits:
-
Object
- Object
- Moped::ReadPreference::SecondaryPreferred
- Includes:
- Selectable
- Defined in:
- lib/moped/read_preference/secondary_preferred.rb
Overview
Encapsulates behaviour around a secondary read preference.
Instance Attribute Summary
Attributes included from Selectable
Instance Method Summary collapse
-
#name ⇒ Symbol
Get the name for the read preference on the server side.
-
#with_node(cluster, &block) ⇒ Object
Select a secondary node from the cluster.
Methods included from Selectable
Instance Method Details
#name ⇒ Symbol
Get the name for the read preference on the server side.
19 20 21 |
# File 'lib/moped/read_preference/secondary_preferred.rb', line 19 def name :secondaryPreferred end |
#with_node(cluster, &block) ⇒ Object
Note:
If tag sets are provided then secondary selection will need to match the provided tags.
Select a secondary node from the cluster. If no secondary is available then use a primary. If no primary is found then an exception will be raised.
42 43 44 45 46 47 48 49 50 |
# File 'lib/moped/read_preference/secondary_preferred.rb', line 42 def with_node(cluster, &block) with_retry(cluster) do begin cluster.with_secondary(&block) rescue Errors::ConnectionFailure cluster.with_primary(&block) end end end |