Module: Mongo::Retryable
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Forwardable
|
|
| Defined in: | lib/mongo/retryable.rb, lib/mongo/retryable/base_worker.rb, lib/mongo/retryable/read_worker.rb, lib/mongo/retryable/write_worker.rb |
Overview
Defines basic behavior around retrying operations.
Instance Method Summary
-
#read_worker
Internal use only
Internal use only
Returns the read worker for handling retryable reads.
-
#select_server(cluster, server_selector, session, failed_server = nil, error: nil, timeout: nil) ⇒ Mongo::Server
Internal use only
Internal use only
This is a separate method to make it possible for the test suite to assert that server selection is performed during retry attempts.
-
#write_worker
Internal use only
Internal use only
Returns the write worker for handling retryable writes.
-
#deprioritize_server?(cluster, error) ⇒ Boolean
private
Whether the failed server should be deprioritized during server selection for a retry attempt.
Instance Method Details
#deprioritize_server?(cluster, error) ⇒ Boolean (private)
Whether the failed server should be deprioritized during server selection for a retry attempt. For sharded and load-balanced topologies, servers are always deprioritized on any retryable error. For replica sets, servers are only deprioritized when the error carries the SystemOverloadedError label.
# File 'lib/mongo/retryable.rb', line 71
def deprioritize_server?(cluster, error) return true if cluster.sharded? || cluster.load_balanced? error.respond_to?(:label?) && error.label?('SystemOverloadedError') end
#read_worker
this is only a public method so that tests can add expectations based on it.
Returns the read worker for handling retryable reads.
# File 'lib/mongo/retryable.rb', line 85
def read_worker @read_worker ||= ReadWorker.new(self) end
#select_server(cluster, server_selector, session, failed_server = nil, error: nil, timeout: nil) ⇒ Mongo::Server
This is a separate method to make it possible for the test suite to assert that server selection is performed during retry attempts.
This is a public method so that it can be accessed via the read and write worker delegates, as needed.
# File 'lib/mongo/retryable.rb', line 49
def select_server(cluster, server_selector, session, failed_server = nil, error: nil, timeout: nil) deprioritized = if failed_server && deprioritize_server?(cluster, error) [failed_server] else [] end server_selector.select_server( cluster, nil, session, deprioritized: deprioritized, timeout: timeout ) end
#write_worker
this is only a public method so that tests can add expectations based on it.
Returns the write worker for handling retryable writes.
# File 'lib/mongo/retryable.rb', line 95
def write_worker @write_worker ||= WriteWorker.new(self) end