OpenQuizz
Une application de gestion des contenus pédagogiques
SocketInfo Class Reference
Inheritance diagram for SocketInfo:
Collaboration diagram for SocketInfo:

Public Member Functions

def __init__ (self, sock, pool, address, id)
 
def ismaster (self, all_credentials=None)
 
def command (self, dbname, spec, slave_ok=False, read_preference=ReadPreference.PRIMARY, codec_options=DEFAULT_CODEC_OPTIONS, check=True, allowable_errors=None, check_keys=False, read_concern=None, write_concern=None, parse_write_concern_error=False, collation=None, session=None, client=None, retryable_write=False, publish_events=True, user_fields=None, exhaust_allowed=False)
 
def send_message (self, message, max_doc_size)
 
def receive_message (self, request_id)
 
def legacy_write (self, request_id, msg, max_doc_size, with_last_error)
 
def write_command (self, request_id, msg)
 
def check_auth (self, all_credentials)
 
def authenticate (self, credentials)
 
def validate_session (self, client, session)
 
def close_socket (self, reason)
 
def socket_closed (self)
 
def send_cluster_time (self, command, session, client)
 
def update_last_checkin_time (self)
 
def update_is_writable (self, is_writable)
 
def idle_time_seconds (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __hash__ (self)
 
def __repr__ (self)
 

Data Fields

 sock
 
 address
 
 id
 
 authset
 
 closed
 
 last_checkin_time
 
 performed_handshake
 
 is_writable
 
 max_wire_version
 
 max_bson_size
 
 max_message_size
 
 max_write_batch_size
 
 supports_sessions
 
 is_mongos
 
 op_msg_enabled
 
 listeners
 
 enabled_for_cmap
 
 compression_settings
 
 compression_context
 
 socket_checker
 
 negotiated_mechanisms
 
 auth_ctx
 
 generation
 
 ready
 
 cancel_context
 
 opts
 
 more_to_come
 

Detailed Description

Store a socket with some metadata.

:Parameters:
  - `sock`: a raw socket object
  - `pool`: a Pool instance
  - `address`: the server's (host, port)
  - `id`: the id of this socket in it's pool

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  sock,
  pool,
  address,
  id 
)

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)

◆ __hash__()

def __hash__ (   self)

◆ __ne__()

def __ne__ (   self,
  other 
)

◆ __repr__()

def __repr__ (   self)

◆ authenticate()

def authenticate (   self,
  credentials 
)
Log in to the server and store these credentials in `authset`.

Can raise ConnectionFailure or OperationFailure.

:Parameters:
  - `credentials`: A MongoCredential.

◆ check_auth()

def check_auth (   self,
  all_credentials 
)
Update this socket's authentication.

Log in or out to bring this socket's credentials up to date with
those provided. Can raise ConnectionFailure or OperationFailure.

:Parameters:
  - `all_credentials`: dict, maps auth source to MongoCredential.

◆ close_socket()

def close_socket (   self,
  reason 
)
Close this connection with a reason.

◆ command()

def command (   self,
  dbname,
  spec,
  slave_ok = False,
  read_preference = ReadPreference.PRIMARY,
  codec_options = DEFAULT_CODEC_OPTIONS,
  check = True,
  allowable_errors = None,
  check_keys = False,
  read_concern = None,
  write_concern = None,
  parse_write_concern_error = False,
  collation = None,
  session = None,
  client = None,
  retryable_write = False,
  publish_events = True,
  user_fields = None,
  exhaust_allowed = False 
)
Execute a command or raise an error.

:Parameters:
  - `dbname`: name of the database on which to run the command
  - `spec`: a command document as a dict, SON, or mapping object
  - `slave_ok`: whether to set the SlaveOkay wire protocol bit
  - `read_preference`: a read preference
  - `codec_options`: a CodecOptions instance
  - `check`: raise OperationFailure if there are errors
  - `allowable_errors`: errors to ignore if `check` is True
  - `check_keys`: if True, check `spec` for invalid keys
  - `read_concern`: The read concern for this command.
  - `write_concern`: The write concern for this command.
  - `parse_write_concern_error`: Whether to parse the
    ``writeConcernError`` field in the command response.
  - `collation`: The collation for this command.
  - `session`: optional ClientSession instance.
  - `client`: optional MongoClient for gossipping $clusterTime.
  - `retryable_write`: True if this command is a retryable write.
  - `publish_events`: Should we publish events for this command?
  - `user_fields` (optional): Response fields that should be decoded
    using the TypeDecoders from codec_options, passed to
    bson._decode_all_selective.

◆ idle_time_seconds()

def idle_time_seconds (   self)
Seconds since this socket was last checked into its pool.

◆ ismaster()

def ismaster (   self,
  all_credentials = None 
)

◆ legacy_write()

def legacy_write (   self,
  request_id,
  msg,
  max_doc_size,
  with_last_error 
)
Send OP_INSERT, etc., optionally returning response as a dict.

Can raise ConnectionFailure or OperationFailure.

:Parameters:
  - `request_id`: an int.
  - `msg`: bytes, an OP_INSERT, OP_UPDATE, or OP_DELETE message,
    perhaps with a getlasterror command appended.
  - `max_doc_size`: size in bytes of the largest document in `msg`.
  - `with_last_error`: True if a getlasterror command is appended.

◆ receive_message()

def receive_message (   self,
  request_id 
)
Receive a raw BSON message or raise ConnectionFailure.

If any exception is raised, the socket is closed.

◆ send_cluster_time()

def send_cluster_time (   self,
  command,
  session,
  client 
)
Add cluster time for MongoDB >= 3.6.

◆ send_message()

def send_message (   self,
  message,
  max_doc_size 
)
Send a raw BSON message or raise ConnectionFailure.

If a network exception is raised, the socket is closed.

◆ socket_closed()

def socket_closed (   self)
Return True if we know socket has been closed, False otherwise.

◆ update_is_writable()

def update_is_writable (   self,
  is_writable 
)

◆ update_last_checkin_time()

def update_last_checkin_time (   self)

◆ validate_session()

def validate_session (   self,
  client,
  session 
)
Validate this session before use with client.

Raises error if this session is logged in as a different user or
the client is not the one that created the session.

◆ write_command()

def write_command (   self,
  request_id,
  msg 
)
Send "insert" etc. command, returning response as a dict.

Can raise ConnectionFailure or OperationFailure.

:Parameters:
  - `request_id`: an int.
  - `msg`: bytes, the command message.

Field Documentation

◆ address

address

◆ auth_ctx

auth_ctx

◆ authset

authset

◆ cancel_context

cancel_context

◆ closed

closed

◆ compression_context

compression_context

◆ compression_settings

compression_settings

◆ enabled_for_cmap

enabled_for_cmap

◆ generation

generation

◆ id

id

◆ is_mongos

is_mongos

◆ is_writable

is_writable

◆ last_checkin_time

last_checkin_time

◆ listeners

listeners

◆ max_bson_size

max_bson_size

◆ max_message_size

max_message_size

◆ max_wire_version

max_wire_version

◆ max_write_batch_size

max_write_batch_size

◆ more_to_come

more_to_come

◆ negotiated_mechanisms

negotiated_mechanisms

◆ op_msg_enabled

op_msg_enabled

◆ opts

opts

◆ performed_handshake

performed_handshake

◆ ready

ready

◆ sock

sock

◆ socket_checker

socket_checker

◆ supports_sessions

supports_sessions

The documentation for this class was generated from the following file: