Exception: Mongo::Error::NoServiceConnectionAvailable

Inherits:
Mongo::Error
  • Object
show all
Defined in:
build/ruby-driver-v2.19/lib/mongo/error/no_service_connection_available.rb

Overview

Raised when the driver requires a connection to a particular service but no matching connections exist in the connection pool.

Since:

  • 2.0.0

Constant Summary

Constants inherited from Mongo::Error

BAD_VALUE, CODE, CURSOR_NOT_FOUND, ERR, ERRMSG, ERROR, TRANSIENT_TRANSACTION_ERROR_LABEL, UNKNOWN_ERROR, UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL, WRITE_CONCERN_ERROR, WRITE_CONCERN_ERRORS, WRITE_ERRORS

Instance Attribute Summary collapse

Attributes included from Notable

#connection_global_id, #generation

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mongo::Error

#change_stream_resumable?, #write_concern_error_label?, #write_concern_error_labels

Methods included from ChangeStreamResumable

#change_stream_resumable?

Methods included from WriteRetryable

#write_retryable?

Methods included from Labelable

#add_label, #label?, #labels

Methods included from Notable

#add_note, #add_notes, #notes, #to_s

Constructor Details

#initialize(message, address:, service_id:) ⇒ NoServiceConnectionAvailable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NoServiceConnectionAvailable.

Since:

  • 2.0.0



25
26
27
28
29
30
# File 'build/ruby-driver-v2.19/lib/mongo/error/no_service_connection_available.rb', line 25

def initialize(message, address:, service_id:)
  super(message)

  @address = address
  @service_id = service_id
end

Instance Attribute Details

#addressMongo::Address (readonly)

Returns The address to which a connection was requested.

Returns:

  • (Mongo::Address)

    The address to which a connection was requested.

Since:

  • 2.0.0



34
35
36
# File 'build/ruby-driver-v2.19/lib/mongo/error/no_service_connection_available.rb', line 34

def address
  @address
end

#service_idnil | Object (readonly)

Returns The service id.

Returns:

  • (nil | Object)

    The service id.

Since:

  • 2.0.0



37
38
39
# File 'build/ruby-driver-v2.19/lib/mongo/error/no_service_connection_available.rb', line 37

def service_id
  @service_id
end

Class Method Details

.generate(address:, service_id:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



40
41
42
43
44
45
46
# File 'build/ruby-driver-v2.19/lib/mongo/error/no_service_connection_available.rb', line 40

def self.generate(address:, service_id:)
  new(
    "The connection pool for #{address} does not have a connection for service #{service_id}",
    address: address,
    service_id: service_id,
  )
end