o
    Åîï]·Å  ã                   @   sº  d Z ddlmZ ddlmZ ddlmZ eddƒZeg g g g g ƒZG dd„ de	ƒZ
G d	d
„ d
e
ƒZG dd„ de
ƒZG dd„ de
ƒZG dd„ de
ƒZG dd„ de
ƒZdd„ Zdd„ Zdd„ Zeg d¢ƒZG dd„ de	ƒZG dd„ deƒZG dd„ deƒZG d d!„ d!eƒZG d"d#„ d#e	ƒZG d$d%„ d%eƒZG d&d'„ d'eƒZG d(d)„ d)eƒZG d*d+„ d+e	ƒZG d,d-„ d-e	ƒZG d.d/„ d/e	ƒZG d0d1„ d1eƒZ G d2d3„ d3eƒZ!G d4d5„ d5eƒZ"G d6d7„ d7e	ƒZ#G d8d9„ d9e	ƒZ$G d:d;„ d;eƒZ%G d<d=„ d=eƒZ&G d>d?„ d?e	ƒZ'G d@dA„ dAe'ƒZ(G dBdC„ dCe'ƒZ)G dDdE„ dEe'ƒZ*G dFdG„ dGe	ƒZ+G dHdI„ dIe+ƒZ,G dJdK„ dKe+ƒZ-G dLdM„ dMe+ƒZ.G dNdO„ dOe	ƒZ/G dPdQ„ dQe/ƒZ0G dRdS„ dSe/ƒZ1G dTdU„ dUe/ƒZ2G dVdW„ dWe	ƒZ3dXS )Ya\  Tools to monitor driver events.

.. versionadded:: 3.1

Use :func:`register` to register global listeners for specific events.
Listeners must inherit from one of the abstract classes below and implement
the correct functions for that class.

For example, a simple command logger might be implemented like this::

    import logging

    from pymongo import monitoring

    class CommandLogger(monitoring.CommandListener):

        def started(self, event):
            logging.info("Command {0.command_name} with request id "
                         "{0.request_id} started on server "
                         "{0.connection_id}".format(event))

        def succeeded(self, event):
            logging.info("Command {0.command_name} with request id "
                         "{0.request_id} on server {0.connection_id} "
                         "succeeded in {0.duration_micros} "
                         "microseconds".format(event))

        def failed(self, event):
            logging.info("Command {0.command_name} with request id "
                         "{0.request_id} on server {0.connection_id} "
                         "failed in {0.duration_micros} "
                         "microseconds".format(event))

    monitoring.register(CommandLogger())

Server discovery and monitoring events are also available. For example::

    class ServerLogger(monitoring.ServerListener):

        def opened(self, event):
            logging.info("Server {0.server_address} added to topology "
                         "{0.topology_id}".format(event))

        def description_changed(self, event):
            previous_server_type = event.previous_description.server_type
            new_server_type = event.new_description.server_type
            if new_server_type != previous_server_type:
                # server_type_name was added in PyMongo 3.4
                logging.info(
                    "Server {0.server_address} changed type from "
                    "{0.previous_description.server_type_name} to "
                    "{0.new_description.server_type_name}".format(event))

        def closed(self, event):
            logging.warning("Server {0.server_address} removed from topology "
                            "{0.topology_id}".format(event))


    class HeartbeatLogger(monitoring.ServerHeartbeatListener):

        def started(self, event):
            logging.info("Heartbeat sent to server "
                         "{0.connection_id}".format(event))

        def succeeded(self, event):
            # The reply.document attribute was added in PyMongo 3.4.
            logging.info("Heartbeat to server {0.connection_id} "
                         "succeeded with reply "
                         "{0.reply.document}".format(event))

        def failed(self, event):
            logging.warning("Heartbeat to server {0.connection_id} "
                            "failed with error {0.reply}".format(event))

    class TopologyLogger(monitoring.TopologyListener):

        def opened(self, event):
            logging.info("Topology with id {0.topology_id} "
                         "opened".format(event))

        def description_changed(self, event):
            logging.info("Topology description updated for "
                         "topology id {0.topology_id}".format(event))
            previous_topology_type = event.previous_description.topology_type
            new_topology_type = event.new_description.topology_type
            if new_topology_type != previous_topology_type:
                # topology_type_name was added in PyMongo 3.4
                logging.info(
                    "Topology {0.topology_id} changed type from "
                    "{0.previous_description.topology_type_name} to "
                    "{0.new_description.topology_type_name}".format(event))
            # The has_writable_server and has_readable_server methods
            # were added in PyMongo 3.4.
            if not event.new_description.has_writable_server():
                logging.warning("No writable servers available.")
            if not event.new_description.has_readable_server():
                logging.warning("No readable servers available.")

        def closed(self, event):
            logging.info("Topology with id {0.topology_id} "
                         "closed".format(event))

Connection monitoring and pooling events are also available. For example::

    class ConnectionPoolLogger(ConnectionPoolListener):

        def pool_created(self, event):
            logging.info("[pool {0.address}] pool created".format(event))

        def pool_cleared(self, event):
            logging.info("[pool {0.address}] pool cleared".format(event))

        def pool_closed(self, event):
            logging.info("[pool {0.address}] pool closed".format(event))

        def connection_created(self, event):
            logging.info("[pool {0.address}][conn #{0.connection_id}] "
                         "connection created".format(event))

        def connection_ready(self, event):
            logging.info("[pool {0.address}][conn #{0.connection_id}] "
                         "connection setup succeeded".format(event))

        def connection_closed(self, event):
            logging.info("[pool {0.address}][conn #{0.connection_id}] "
                         "connection closed, reason: "
                         "{0.reason}".format(event))

        def connection_check_out_started(self, event):
            logging.info("[pool {0.address}] connection check out "
                         "started".format(event))

        def connection_check_out_failed(self, event):
            logging.info("[pool {0.address}] connection check out "
                         "failed, reason: {0.reason}".format(event))

        def connection_checked_out(self, event):
            logging.info("[pool {0.address}][conn #{0.connection_id}] "
                         "connection checked out of pool".format(event))

        def connection_checked_in(self, event):
            logging.info("[pool {0.address}][conn #{0.connection_id}] "
                         "connection checked into pool".format(event))


Event listeners can also be registered per instance of
:class:`~pymongo.mongo_client.MongoClient`::

    client = MongoClient(event_listeners=[CommandLogger()])

Note that previously registered global listeners are automatically included
when configuring per client event listeners. Registering a new global listener
will not add that listener to existing client instances.

.. note:: Events are delivered **synchronously**. Application threads block
  waiting for event handlers (e.g. :meth:`~CommandListener.started`) to
  return. Care must be taken to ensure that your event handlers are efficient
  enough to not adversely affect overall application performance.

.. warning:: The command documents published through this API are *not* copies.
  If you intend to modify them in any way you must copy them in your event
  handler first.
é    )Ú
namedtuple)Úabc)Ú_handle_exceptionÚ	Listeners)Úcommand_listenersÚserver_listenersÚserver_heartbeat_listenersÚtopology_listenersÚcmap_listenersc                   @   s   e Zd ZdZdS )Ú_EventListenerz,Abstract base class for all event listeners.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úD/var/www/html/env/lib/python3.10/site-packages/pymongo/monitoring.pyr   À   s    r   c                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚCommandListenerzŠAbstract base class for command listeners.

    Handles `CommandStartedEvent`, `CommandSucceededEvent`,
    and `CommandFailedEvent`.
    c                 C   ó   t ‚)z“Abstract method to handle a `CommandStartedEvent`.

        :Parameters:
          - `event`: An instance of :class:`CommandStartedEvent`.
        ©ÚNotImplementedError©ÚselfÚeventr   r   r   ÚstartedË   ó   zCommandListener.startedc                 C   r   )z—Abstract method to handle a `CommandSucceededEvent`.

        :Parameters:
          - `event`: An instance of :class:`CommandSucceededEvent`.
        r   r   r   r   r   Ú	succeededÓ   r   zCommandListener.succeededc                 C   r   )z‘Abstract method to handle a `CommandFailedEvent`.

        :Parameters:
          - `event`: An instance of :class:`CommandFailedEvent`.
        r   r   r   r   r   ÚfailedÛ   r   zCommandListener.failedN©r   r   r   r   r   r   r   r   r   r   r   r   Ä   s
    r   c                   @   s`   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚConnectionPoolListenera-  Abstract base class for connection pool listeners.

    Handles all of the connection pool events defined in the Connection
    Monitoring and Pooling Specification:
    :class:`PoolCreatedEvent`, :class:`PoolClearedEvent`,
    :class:`PoolClosedEvent`, :class:`ConnectionCreatedEvent`,
    :class:`ConnectionReadyEvent`, :class:`ConnectionClosedEvent`,
    :class:`ConnectionCheckOutStartedEvent`,
    :class:`ConnectionCheckOutFailedEvent`,
    :class:`ConnectionCheckedOutEvent`,
    and :class:`ConnectionCheckedInEvent`.

    .. versionadded:: 3.9
    c                 C   r   )zÈAbstract method to handle a :class:`PoolCreatedEvent`.

        Emitted when a Connection Pool is created.

        :Parameters:
          - `event`: An instance of :class:`PoolCreatedEvent`.
        r   r   r   r   r   Úpool_createdô   ó   z#ConnectionPoolListener.pool_createdc                 C   r   )zÁAbstract method to handle a `PoolClearedEvent`.

        Emitted when a Connection Pool is cleared.

        :Parameters:
          - `event`: An instance of :class:`PoolClearedEvent`.
        r   r   r   r   r   Úpool_clearedþ   r!   z#ConnectionPoolListener.pool_clearedc                 C   r   )z¾Abstract method to handle a `PoolClosedEvent`.

        Emitted when a Connection Pool is closed.

        :Parameters:
          - `event`: An instance of :class:`PoolClosedEvent`.
        r   r   r   r   r   Úpool_closed  r!   z"ConnectionPoolListener.pool_closedc                 C   r   )zåAbstract method to handle a :class:`ConnectionCreatedEvent`.

        Emitted when a Connection Pool creates a Connection object.

        :Parameters:
          - `event`: An instance of :class:`ConnectionCreatedEvent`.
        r   r   r   r   r   Úconnection_created  r!   z)ConnectionPoolListener.connection_createdc                 C   r   )zøAbstract method to handle a :class:`ConnectionReadyEvent`.

        Emitted when a Connection has finished its setup, and is now ready to
        use.

        :Parameters:
          - `event`: An instance of :class:`ConnectionReadyEvent`.
        r   r   r   r   r   Úconnection_ready  ó   	z'ConnectionPoolListener.connection_readyc                 C   r   )zÛAbstract method to handle a :class:`ConnectionClosedEvent`.

        Emitted when a Connection Pool closes a Connection.

        :Parameters:
          - `event`: An instance of :class:`ConnectionClosedEvent`.
        r   r   r   r   r   Úconnection_closed'  r!   z(ConnectionPoolListener.connection_closedc                 C   r   )zþAbstract method to handle a :class:`ConnectionCheckOutStartedEvent`.

        Emitted when the driver starts attempting to check out a connection.

        :Parameters:
          - `event`: An instance of :class:`ConnectionCheckOutStartedEvent`.
        r   r   r   r   r   Úconnection_check_out_started1  r!   z3ConnectionPoolListener.connection_check_out_startedc                 C   r   )zúAbstract method to handle a :class:`ConnectionCheckOutFailedEvent`.

        Emitted when the driver's attempt to check out a connection fails.

        :Parameters:
          - `event`: An instance of :class:`ConnectionCheckOutFailedEvent`.
        r   r   r   r   r   Úconnection_check_out_failed;  r!   z2ConnectionPoolListener.connection_check_out_failedc                 C   r   )zíAbstract method to handle a :class:`ConnectionCheckedOutEvent`.

        Emitted when the driver successfully checks out a Connection.

        :Parameters:
          - `event`: An instance of :class:`ConnectionCheckedOutEvent`.
        r   r   r   r   r   Úconnection_checked_outE  r!   z-ConnectionPoolListener.connection_checked_outc                 C   r   )a  Abstract method to handle a :class:`ConnectionCheckedInEvent`.

        Emitted when the driver checks in a Connection back to the Connection
        Pool.

        :Parameters:
          - `event`: An instance of :class:`ConnectionCheckedInEvent`.
        r   r   r   r   r   Úconnection_checked_inO  r&   z,ConnectionPoolListener.connection_checked_inN)r   r   r   r   r    r"   r#   r$   r%   r'   r(   r)   r*   r+   r   r   r   r   r   ä   s    







r   c                   @   r   )	ÚServerHeartbeatListenerzÆAbstract base class for server heartbeat listeners.

    Handles `ServerHeartbeatStartedEvent`, `ServerHeartbeatSucceededEvent`,
    and `ServerHeartbeatFailedEvent`.

    .. versionadded:: 3.3
    c                 C   r   )z£Abstract method to handle a `ServerHeartbeatStartedEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerHeartbeatStartedEvent`.
        r   r   r   r   r   r   d  r   zServerHeartbeatListener.startedc                 C   r   )z§Abstract method to handle a `ServerHeartbeatSucceededEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerHeartbeatSucceededEvent`.
        r   r   r   r   r   r   l  r   z!ServerHeartbeatListener.succeededc                 C   r   )z¡Abstract method to handle a `ServerHeartbeatFailedEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerHeartbeatFailedEvent`.
        r   r   r   r   r   r   t  r   zServerHeartbeatListener.failedNr   r   r   r   r   r,   [  s
    r,   c                   @   r   )	ÚTopologyListenerz»Abstract base class for topology monitoring listeners.
    Handles `TopologyOpenedEvent`, `TopologyDescriptionChangedEvent`, and
    `TopologyClosedEvent`.

    .. versionadded:: 3.3
    c                 C   r   )z“Abstract method to handle a `TopologyOpenedEvent`.

        :Parameters:
          - `event`: An instance of :class:`TopologyOpenedEvent`.
        r   r   r   r   r   Úopened…  r   zTopologyListener.openedc                 C   r   )z«Abstract method to handle a `TopologyDescriptionChangedEvent`.

        :Parameters:
          - `event`: An instance of :class:`TopologyDescriptionChangedEvent`.
        r   r   r   r   r   Údescription_changed�  r   z$TopologyListener.description_changedc                 C   r   )z“Abstract method to handle a `TopologyClosedEvent`.

        :Parameters:
          - `event`: An instance of :class:`TopologyClosedEvent`.
        r   r   r   r   r   Úclosed•  r   zTopologyListener.closedN©r   r   r   r   r.   r/   r0   r   r   r   r   r-   }  ó
    r-   c                   @   r   )	ÚServerListenerz©Abstract base class for server listeners.
    Handles `ServerOpeningEvent`, `ServerDescriptionChangedEvent`, and
    `ServerClosedEvent`.

    .. versionadded:: 3.3
    c                 C   r   )z‘Abstract method to handle a `ServerOpeningEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerOpeningEvent`.
        r   r   r   r   r   r.   ¦  r   zServerListener.openedc                 C   r   )z§Abstract method to handle a `ServerDescriptionChangedEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerDescriptionChangedEvent`.
        r   r   r   r   r   r/   ®  r   z"ServerListener.description_changedc                 C   r   )z�Abstract method to handle a `ServerClosedEvent`.

        :Parameters:
          - `event`: An instance of :class:`ServerClosedEvent`.
        r   r   r   r   r   r0   ¶  r   zServerListener.closedNr1   r   r   r   r   r3   ž  r2   r3   c                 C   s   t |  ¡ d ƒS )z'Convert duration 'dur' to microseconds.g    €„.A)ÚintÚtotal_seconds)Údurr   r   r   Ú
_to_micros¿  s   r7   c                 C   s@   t |tjƒstd| f ƒ‚|D ]}t |tƒstd| f ƒ‚q|S )zValidate event listenersz%s must be a list or tupleúˆListeners for %s must be either a CommandListener, ServerHeartbeatListener, ServerListener, TopologyListener, or ConnectionPoolListener.)Ú
isinstancer   ÚSequenceÚ	TypeErrorr   )ÚoptionÚ	listenersÚlistenerr   r   r   Ú_validate_event_listenersÄ  s   
ýÿr?   c                 C   sŽ   t | tƒstd| f ƒ‚t | tƒrtj | ¡ t | tƒr"tj | ¡ t | t	ƒr-tj
 | ¡ t | tƒr8tj | ¡ t | tƒrEtj | ¡ dS dS )a   Register a global event listener.

    :Parameters:
      - `listener`: A subclasses of :class:`CommandListener`,
        :class:`ServerHeartbeatListener`, :class:`ServerListener`,
        :class:`TopologyListener`, or :class:`ConnectionPoolListener`.
    r8   N)r9   r   r;   r   Ú
_LISTENERSr   Úappendr,   r   r3   r   r-   r	   r   r
   )r>   r   r   r   ÚregisterÑ  s   
ý




ÿrB   )	ÚauthenticateÚ	saslstartÚsaslcontinueÚgetnonceÚ
createuserÚ
updateuserÚcopydbgetnonceÚcopydbsaslstartÚcopydbc                   @   sL   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
dS )Ú_CommandEventzBase class for command events.)Ú
__cmd_nameÚ	__rqst_idÚ	__conn_idÚ__op_idc                 C   s   || _ || _|| _|| _d S ©N)Ú_CommandEvent__cmd_nameÚ_CommandEvent__rqst_idÚ_CommandEvent__conn_idÚ_CommandEvent__op_id)r   Úcommand_nameÚ
request_idÚconnection_idÚoperation_idr   r   r   Ú__init__ö  s   
z_CommandEvent.__init__c                 C   ó   | j S )zThe command name.)rR   ©r   r   r   r   rV   ü  ó   z_CommandEvent.command_namec                 C   r[   )z"The request id for this operation.)rS   r\   r   r   r   rW     r]   z_CommandEvent.request_idc                 C   r[   )z@The address (host, port) of the server this command was sent to.)rT   r\   r   r   r   rX     r]   z_CommandEvent.connection_idc                 C   r[   )z(An id for this series of events or None.)rU   r\   r   r   r   rY     r]   z_CommandEvent.operation_idN)r   r   r   r   Ú	__slots__rZ   ÚpropertyrV   rW   rX   rY   r   r   r   r   rL   ñ  s    


rL   c                       ó<   e Zd ZdZdZ‡ fdd„Zedd„ ƒZedd„ ƒZ‡  Z	S )	ÚCommandStartedEventa   Event published when a command starts.

    :Parameters:
      - `command`: The command document.
      - `database_name`: The name of the database this command was run against.
      - `request_id`: The request id for this operation.
      - `connection_id`: The address (host, port) of the server this command
        was sent to.
      - `operation_id`: An optional identifier for a series of related events.
    )Ú__cmdÚ__dbc                    sZ   |s	t d|f ƒ‚tt|ƒƒ}tt| ƒj|g|¢R Ž  | ¡ tv r%i | _n|| _|| _	d S )Nz%r is not a valid command)
Ú
ValueErrorÚnextÚiterÚsuperra   rZ   ÚlowerÚ_SENSITIVE_COMMANDSÚ_CommandStartedEvent__cmdÚ_CommandStartedEvent__db)r   ÚcommandÚdatabase_nameÚargsrV   ©Ú	__class__r   r   rZ     s   
zCommandStartedEvent.__init__c                 C   r[   )zThe command document.)rj   r\   r   r   r   rl   *  r]   zCommandStartedEvent.commandc                 C   r[   )z6The name of the database this command was run against.)rk   r\   r   r   r   rm   /  r]   z!CommandStartedEvent.database_name)
r   r   r   r   r^   rZ   r_   rl   rm   Ú__classcell__r   r   ro   r   ra     s    

ra   c                       r`   )	ÚCommandSucceededEventaÁ  Event published when a command succeeds.

    :Parameters:
      - `duration`: The command duration as a datetime.timedelta.
      - `reply`: The server reply document.
      - `command_name`: The command name.
      - `request_id`: The request id for this operation.
      - `connection_id`: The address (host, port) of the server this command
        was sent to.
      - `operation_id`: An optional identifier for a series of related events.
    )Ú__duration_microsÚ__replyc                    s@   t t| ƒ ||||¡ t|ƒ| _| ¡ tv ri | _d S || _d S rQ   )rg   rr   rZ   r7   Ú'_CommandSucceededEvent__duration_microsrh   ri   Ú_CommandSucceededEvent__reply)r   ÚdurationÚreplyrV   rW   rX   rY   ro   r   r   rZ   C  s   
ÿ


zCommandSucceededEvent.__init__c                 C   r[   ©z/The duration of this operation in microseconds.)ru   r\   r   r   r   Úduration_microsM  r]   z%CommandSucceededEvent.duration_microsc                 C   r[   ©z/The server failure document for this operation.)rv   r\   r   r   r   rx   R  r]   zCommandSucceededEvent.reply)
r   r   r   r   r^   rZ   r_   rz   rx   rq   r   r   ro   r   rr   5  s    

rr   c                       r`   )	ÚCommandFailedEventaÀ  Event published when a command fails.

    :Parameters:
      - `duration`: The command duration as a datetime.timedelta.
      - `failure`: The server reply document.
      - `command_name`: The command name.
      - `request_id`: The request id for this operation.
      - `connection_id`: The address (host, port) of the server this command
        was sent to.
      - `operation_id`: An optional identifier for a series of related events.
    )rs   Ú	__failurec                    s$   t t| ƒj|Ž  t|ƒ| _|| _d S rQ   )rg   r|   rZ   r7   Ú$_CommandFailedEvent__duration_microsÚ_CommandFailedEvent__failure)r   rw   Úfailurern   ro   r   r   rZ   f  s   

zCommandFailedEvent.__init__c                 C   r[   ry   )r~   r\   r   r   r   rz   k  r]   z"CommandFailedEvent.duration_microsc                 C   r[   r{   )r   r\   r   r   r   r€   p  r]   zCommandFailedEvent.failure)
r   r   r   r   r^   rZ   r_   rz   r€   rq   r   r   ro   r   r|   X  s    
r|   c                   @   ó0   e Zd ZdZdZdd„ Zedd„ ƒZdd„ Zd	S )
Ú
_PoolEventzBase class for pool events.©Ú	__addressc                 C   ó
   || _ d S rQ   ©Ú_PoolEvent__address©r   Úaddressr   r   r   rZ   z  ó   
z_PoolEvent.__init__c                 C   r[   )zbThe address (host, port) pair of the server the pool is attempting
        to connect to.
        r†   r\   r   r   r   r‰   }  ó   z_PoolEvent.addressc                 C   ó   d| j j| jf S ©Nz%s(%r))rp   r   r‡   r\   r   r   r   Ú__repr__„  ó   z_PoolEvent.__repr__N©	r   r   r   r   r^   rZ   r_   r‰   rŽ   r   r   r   r   r‚   v  s    
r‚   c                       ó8   e Zd ZdZdZ‡ fdd„Zedd„ ƒZdd„ Z‡  Z	S )	ÚPoolCreatedEventzÊPublished when a Connection Pool is created.

    :Parameters:
     - `address`: The address (host, port) pair of the server this Pool is
       attempting to connect to.

    .. versionadded:: 3.9
    )Ú	__optionsc                    s   t t| ƒ |¡ || _d S rQ   )rg   r’   rZ   Ú_PoolCreatedEvent__options)r   r‰   Úoptionsro   r   r   rZ   “  s   
zPoolCreatedEvent.__init__c                 C   r[   )zLAny non-default pool options that were set on this Connection Pool.
        )r”   r\   r   r   r   r•   —  ó   zPoolCreatedEvent.optionsc                 C   ó   d| j j| j| jf S ©Nz
%s(%r, %r))rp   r   r‰   r”   r\   r   r   r   rŽ   �  ó   ÿzPoolCreatedEvent.__repr__)
r   r   r   r   r^   rZ   r_   r•   rŽ   rq   r   r   ro   r   r’   ˆ  s    
r’   c                   @   ó   e Zd ZdZdZdS )ÚPoolClearedEventzÊPublished when a Connection Pool is cleared.

    :Parameters:
     - `address`: The address (host, port) pair of the server this Pool is
       attempting to connect to.

    .. versionadded:: 3.9
    r   N©r   r   r   r   r^   r   r   r   r   r›   ¢  ó    r›   c                   @   rš   )ÚPoolClosedEventzÉPublished when a Connection Pool is closed.

    :Parameters:
     - `address`: The address (host, port) pair of the server this Pool is
       attempting to connect to.

    .. versionadded:: 3.9
    r   Nrœ   r   r   r   r   rž   ®  r�   rž   c                   @   s&   e Zd ZdZdZ	 dZ	 dZ	 dZdS )ÚConnectionClosedReasonzqAn enum that defines values for `reason` on a
    :class:`ConnectionClosedEvent`.

    .. versionadded:: 3.9
    ÚstaleÚidleÚerrorÚ
poolClosedN)r   r   r   r   ÚSTALEÚIDLEÚERRORÚPOOL_CLOSEDr   r   r   r   rŸ   º  s    rŸ   c                   @   s    e Zd ZdZdZ	 dZ	 dZdS )ÚConnectionCheckOutFailedReasonzyAn enum that defines values for `reason` on a
    :class:`ConnectionCheckOutFailedEvent`.

    .. versionadded:: 3.9
    Útimeoutr£   ÚconnectionErrorN)r   r   r   r   ÚTIMEOUTr§   Ú
CONN_ERRORr   r   r   r   r¨   Ï  s    r¨   c                   @   ó<   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZd	d
„ Z	dS )Ú_ConnectionEventz.Private base class for some connection events.)r„   Ú__connection_idc                 C   ó   || _ || _d S rQ   )Ú_ConnectionEvent__addressÚ_ConnectionEvent__connection_id)r   r‰   rX   r   r   r   rZ   æ  ó   
z_ConnectionEvent.__init__c                 C   r[   ©ziThe address (host, port) pair of the server this connection is
        attempting to connect to.
        )r±   r\   r   r   r   r‰   ê  r‹   z_ConnectionEvent.addressc                 C   r[   )zThe ID of the Connection.)r²   r\   r   r   r   rX   ñ  r]   z_ConnectionEvent.connection_idc                 C   r—   r˜   )rp   r   r±   r²   r\   r   r   r   rŽ   ö  r™   z_ConnectionEvent.__repr__N)
r   r   r   r   r^   rZ   r_   r‰   rX   rŽ   r   r   r   r   r®   â  s    

r®   c                   @   rš   )ÚConnectionCreatedEventa’  Published when a Connection Pool creates a Connection object.

    NOTE: This connection is not ready for use until the
    :class:`ConnectionReadyEvent` is published.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `connection_id`: The integer ID of the Connection in this Pool.

    .. versionadded:: 3.9
    r   Nrœ   r   r   r   r   rµ   û  s    rµ   c                   @   rš   )ÚConnectionReadyEventa3  Published when a Connection has finished its setup, and is ready to use.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `connection_id`: The integer ID of the Connection in this Pool.

    .. versionadded:: 3.9
    r   Nrœ   r   r   r   r   r¶     ó    	r¶   c                       r‘   )	ÚConnectionClosedEventaV  Published when a Connection is closed.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `connection_id`: The integer ID of the Connection in this Pool.
     - `reason`: A reason explaining why this connection was closed.

    .. versionadded:: 3.9
    )Ú__reasonc                    s   t t| ƒ ||¡ || _d S rQ   )rg   r¸   rZ   Ú_ConnectionClosedEvent__reason)r   r‰   rX   Úreasonro   r   r   rZ   %  s   
zConnectionClosedEvent.__init__c                 C   r[   )z¢A reason explaining why this connection was closed.

        The reason must be one of the strings from the
        :class:`ConnectionClosedReason` enum.
        )rº   r\   r   r   r   r»   )  ó   zConnectionClosedEvent.reasonc                 C   s   d| j j| j| j| jf S )Nz%s(%r, %r, %r))rp   r   r‰   rX   rº   r\   r   r   r   rŽ   2  s   þzConnectionClosedEvent.__repr__)
r   r   r   r   r^   rZ   r_   r»   rŽ   rq   r   r   ro   r   r¸     s    

r¸   c                   @   r�   )
ÚConnectionCheckOutStartedEventzêPublished when the driver starts attempting to check out a connection.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.

    .. versionadded:: 3.9
    rƒ   c                 C   r…   rQ   ©Ú(_ConnectionCheckOutStartedEvent__addressrˆ   r   r   r   rZ   C  rŠ   z'ConnectionCheckOutStartedEvent.__init__c                 C   r[   r´   r¾   r\   r   r   r   r‰   F  r‹   z&ConnectionCheckOutStartedEvent.addressc                 C   rŒ   r�   )rp   r   r¿   r\   r   r   r   rŽ   M  r�   z'ConnectionCheckOutStartedEvent.__repr__Nr�   r   r   r   r   r½   8  s    
r½   c                   @   r­   )ÚConnectionCheckOutFailedEventa.  Published when the driver's attempt to check out a connection fails.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `reason`: A reason explaining why connection check out failed.

    .. versionadded:: 3.9
    )r„   r¹   c                 C   r°   rQ   )Ú'_ConnectionCheckOutFailedEvent__addressÚ&_ConnectionCheckOutFailedEvent__reason)r   r‰   r»   r   r   r   rZ   ]  r³   z&ConnectionCheckOutFailedEvent.__init__c                 C   r[   r´   )rÁ   r\   r   r   r   r‰   a  r‹   z%ConnectionCheckOutFailedEvent.addressc                 C   r[   )z«A reason explaining why connection check out failed.

        The reason must be one of the strings from the
        :class:`ConnectionCheckOutFailedReason` enum.
        )rÂ   r\   r   r   r   r»   h  r¼   z$ConnectionCheckOutFailedEvent.reasonc                 C   r—   r˜   )rp   r   rÁ   rÂ   r\   r   r   r   rŽ   q  r™   z&ConnectionCheckOutFailedEvent.__repr__N)
r   r   r   r   r^   rZ   r_   r‰   r»   rŽ   r   r   r   r   rÀ   Q  s    	

rÀ   c                   @   rš   )ÚConnectionCheckedOutEventa*  Published when the driver successfully checks out a Connection.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `connection_id`: The integer ID of the Connection in this Pool.

    .. versionadded:: 3.9
    r   Nrœ   r   r   r   r   rÃ   v  r·   rÃ   c                   @   rš   )ÚConnectionCheckedInEventa*  Published when the driver checks in a Connection into the Pool.

    :Parameters:
     - `address`: The address (host, port) pair of the server this
       Connection is attempting to connect to.
     - `connection_id`: The integer ID of the Connection in this Pool.

    .. versionadded:: 3.9
    r   Nrœ   r   r   r   r   rÄ   ƒ  r·   rÄ   c                   @   s4   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZd	S )
Ú_ServerEventzBase class for server events.)Ú__server_addressÚ__topology_idc                 C   r°   rQ   )Ú_ServerEvent__server_addressÚ_ServerEvent__topology_id)r   Úserver_addressÚtopology_idr   r   r   rZ   •  r³   z_ServerEvent.__init__c                 C   r[   )z+The address (host, port) pair of the server)rÈ   r\   r   r   r   rÊ   ™  r]   z_ServerEvent.server_addressc                 C   r[   ©z>A unique identifier for the topology this server is a part of.)rÉ   r\   r   r   r   rË   ž  r]   z_ServerEvent.topology_idN)	r   r   r   r   r^   rZ   r_   rÊ   rË   r   r   r   r   rÅ   �  s    
rÅ   c                       r`   )	ÚServerDescriptionChangedEventzJPublished when server description changes.

    .. versionadded:: 3.3
    ©Ú__previous_descriptionÚ__new_descriptionc                    ó    t t| ƒj|Ž  || _|| _d S rQ   )rg   rÍ   rZ   Ú4_ServerDescriptionChangedEvent__previous_descriptionÚ/_ServerDescriptionChangedEvent__new_description©r   Úprevious_descriptionÚnew_descriptionrn   ro   r   r   rZ   ¬  ó   
z&ServerDescriptionChangedEvent.__init__c                 C   r[   )zLThe previous
        :class:`~pymongo.server_description.ServerDescription`.)rÒ   r\   r   r   r   rÕ   ±  r–   z2ServerDescriptionChangedEvent.previous_descriptionc                 C   r[   )zGThe new
        :class:`~pymongo.server_description.ServerDescription`.)rÓ   r\   r   r   r   rÖ   ·  r–   z-ServerDescriptionChangedEvent.new_description©
r   r   r   r   r^   rZ   r_   rÕ   rÖ   rq   r   r   ro   r   rÍ   ¤  ó    
rÍ   c                   @   rš   )ÚServerOpeningEventzEPublished when server is initialized.

    .. versionadded:: 3.3
    r   Nrœ   r   r   r   r   rÚ   ¾  ó    rÚ   c                   @   rš   )ÚServerClosedEventz@Published when server is closed.

    .. versionadded:: 3.3
    r   Nrœ   r   r   r   r   rÜ   Ç  rÛ   rÜ   c                   @   ó(   e Zd ZdZdZdd„ Zedd„ ƒZdS )ÚTopologyEventz+Base class for topology description events.rÇ   c                 C   r…   rQ   ©Ú_TopologyEvent__topology_id)r   rË   r   r   r   rZ   Õ  rŠ   zTopologyEvent.__init__c                 C   r[   rÌ   rß   r\   r   r   r   rË   Ø  r]   zTopologyEvent.topology_idN)r   r   r   r   r^   rZ   r_   rË   r   r   r   r   rÞ   Ð  ó    rÞ   c                       r`   )	ÚTopologyDescriptionChangedEventzPPublished when the topology description changes.

    .. versionadded:: 3.3
    rÎ   c                    rÑ   rQ   )rg   râ   rZ   Ú6_TopologyDescriptionChangedEvent__previous_descriptionÚ1_TopologyDescriptionChangedEvent__new_descriptionrÔ   ro   r   r   rZ   æ  r×   z(TopologyDescriptionChangedEvent.__init__c                 C   r[   )zPThe previous
        :class:`~pymongo.topology_description.TopologyDescription`.)rã   r\   r   r   r   rÕ   ë  r–   z4TopologyDescriptionChangedEvent.previous_descriptionc                 C   r[   )zKThe new
        :class:`~pymongo.topology_description.TopologyDescription`.)rä   r\   r   r   r   rÖ   ñ  r–   z/TopologyDescriptionChangedEvent.new_descriptionrØ   r   r   ro   r   râ   Þ  rÙ   râ   c                   @   rš   )ÚTopologyOpenedEventzKPublished when the topology is initialized.

    .. versionadded:: 3.3
    r   Nrœ   r   r   r   r   rå   ø  rÛ   rå   c                   @   rš   )ÚTopologyClosedEventzFPublished when the topology is closed.

    .. versionadded:: 3.3
    r   Nrœ   r   r   r   r   ræ     rÛ   ræ   c                   @   rÝ   )Ú_ServerHeartbeatEventz'Base class for server heartbeat events.r¯   c                 C   r…   rQ   ©Ú$_ServerHeartbeatEvent__connection_id)r   rX   r   r   r   rZ     rŠ   z_ServerHeartbeatEvent.__init__c                 C   r[   )zJThe address (host, port) of the server this heartbeat was sent
        to.rè   r\   r   r   r   rX     r–   z#_ServerHeartbeatEvent.connection_idN)r   r   r   r   r^   rZ   r_   rX   r   r   r   r   rç   
  rá   rç   c                   @   rš   )ÚServerHeartbeatStartedEventzFPublished when a heartbeat is started.

    .. versionadded:: 3.3
    r   Nrœ   r   r   r   r   rê     rÛ   rê   c                       r`   )	ÚServerHeartbeatSucceededEventzIFired when the server heartbeat succeeds.

    .. versionadded:: 3.3
    ©Ú
__durationrt   c                    rÑ   rQ   )rg   rë   rZ   Ú(_ServerHeartbeatSucceededEvent__durationÚ%_ServerHeartbeatSucceededEvent__reply©r   rw   rx   rn   ro   r   r   rZ   *  r×   z&ServerHeartbeatSucceededEvent.__init__c                 C   r[   ©z/The duration of this heartbeat in microseconds.)rî   r\   r   r   r   rw   /  r]   z&ServerHeartbeatSucceededEvent.durationc                 C   r[   )z3An instance of :class:`~pymongo.ismaster.IsMaster`.)rï   r\   r   r   r   rx   4  r]   z#ServerHeartbeatSucceededEvent.reply©
r   r   r   r   r^   rZ   r_   rw   rx   rq   r   r   ro   r   rë   "  s    
rë   c                       r`   )	ÚServerHeartbeatFailedEventzxFired when the server heartbeat fails, either with an "ok: 0"
    or a socket exception.

    .. versionadded:: 3.3
    rì   c                    rÑ   rQ   )rg   ró   rZ   Ú%_ServerHeartbeatFailedEvent__durationÚ"_ServerHeartbeatFailedEvent__replyrð   ro   r   r   rZ   C  r×   z#ServerHeartbeatFailedEvent.__init__c                 C   r[   rñ   )rô   r\   r   r   r   rw   H  r]   z#ServerHeartbeatFailedEvent.durationc                 C   r[   )zA subclass of :exc:`Exception`.)rõ   r\   r   r   r   rx   M  r]   z ServerHeartbeatFailedEvent.replyrò   r   r   ro   r   ró   :  s    
ró   c                   @   s  e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
dd„ Z	d=dd„Z	d=dd„Z	d=dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Z d;d<„ Z!dS )>Ú_EventListenersz½Configure event listeners for a client instance.

    Any event listeners registered globally are included by default.

    :Parameters:
      - `listeners`: A list of event listeners.
    c                 C   s  t jd d … | _t jd d … | _t j}|d d … | _t jd d … | _t j	d d … | _
|d urj|D ]9}t|tƒr=| j |¡ t|tƒrH| j |¡ t|tƒrS| j |¡ t|tƒr^| j |¡ t|tƒri| j
 |¡ q0t| jƒ| _t| jƒ| _t| jƒ| _t| jƒ| _t| j
ƒ| _d S rQ   )r@   r   Ú"_EventListeners__command_listenersr   Ú!_EventListeners__server_listenersr   Ú+_EventListeners__server_heartbeat_listenersr	   Ú#_EventListeners__topology_listenersr
   Ú_EventListeners__cmap_listenersr9   r   rA   r3   r,   r-   r   ÚboolÚ%_EventListeners__enabled_for_commandsÚ#_EventListeners__enabled_for_serverÚ-_EventListeners__enabled_for_server_heartbeatÚ%_EventListeners__enabled_for_topologyÚ!_EventListeners__enabled_for_cmap)r   r=   Úlstr   r   r   rZ   [  s4   




€ÿz_EventListeners.__init__c                 C   r[   )z-Are any CommandListener instances registered?)rý   r\   r   r   r   Úenabled_for_commandsu  r]   z$_EventListeners.enabled_for_commandsc                 C   r[   )z,Are any ServerListener instances registered?)rþ   r\   r   r   r   Úenabled_for_serverz  r]   z"_EventListeners.enabled_for_serverc                 C   r[   )z5Are any ServerHeartbeatListener instances registered?)rÿ   r\   r   r   r   Úenabled_for_server_heartbeat  r]   z,_EventListeners.enabled_for_server_heartbeatc                 C   r[   )z.Are any TopologyListener instances registered?)r   r\   r   r   r   Úenabled_for_topology„  r]   z$_EventListeners.enabled_for_topologyc                 C   r[   )z4Are any ConnectionPoolListener instances registered?)r  r\   r   r   r   Úenabled_for_cmap‰  r]   z _EventListeners.enabled_for_cmapc                 C   s4   | j dd… | jdd… | jdd… | jdd… fS )z#List of registered event listeners.N)r÷   rù   rø   rú   r\   r   r   r   Úevent_listenersŽ  s
   ýz_EventListeners.event_listenersNc              	   C   sR   |du r|}t |||||ƒ}| jD ]}z| |¡ W q ty&   tƒ  Y qw dS )aÏ  Publish a CommandStartedEvent to all command listeners.

        :Parameters:
          - `command`: The command document.
          - `database_name`: The name of the database this command was run
            against.
          - `request_id`: The request id for this operation.
          - `connection_id`: The address (host, port) of the server this
            command was sent to.
          - `op_id`: The (optional) operation id for this operation.
        N)ra   r÷   r   Ú	Exceptionr   )r   rl   rm   rW   rX   Úop_idr   Ú
subscriberr   r   r   Úpublish_command_start•  s   
ÿ

ÿýz%_EventListeners.publish_command_startc           	   	   C   óT   |du r|}t ||||||ƒ}| jD ]}z| |¡ W q ty'   tƒ  Y qw dS )aè  Publish a CommandSucceededEvent to all command listeners.

        :Parameters:
          - `duration`: The command duration as a datetime.timedelta.
          - `reply`: The server reply document.
          - `command_name`: The command name.
          - `request_id`: The request id for this operation.
          - `connection_id`: The address (host, port) of the server this
            command was sent to.
          - `op_id`: The (optional) operation id for this operation.
        N)rr   r÷   r   r	  r   )	r   rw   rx   rV   rW   rX   r
  r   r  r   r   r   Úpublish_command_success¬  s   ÿ

ÿýz'_EventListeners.publish_command_successc           	   	   C   r  )a  Publish a CommandFailedEvent to all command listeners.

        :Parameters:
          - `duration`: The command duration as a datetime.timedelta.
          - `failure`: The server reply document or failure description
            document.
          - `command_name`: The command name.
          - `request_id`: The request id for this operation.
          - `connection_id`: The address (host, port) of the server this
            command was sent to.
          - `op_id`: The (optional) operation id for this operation.
        N)r|   r÷   r   r	  r   )	r   rw   r€   rV   rW   rX   r
  r   r  r   r   r   Úpublish_command_failureÃ  s   ÿ

ÿýz'_EventListeners.publish_command_failurec              	   C   ó>   t |ƒ}| jD ]}z| |¡ W q ty   tƒ  Y qw dS )z¼Publish a ServerHeartbeatStartedEvent to all server heartbeat
        listeners.

        :Parameters:
         - `connection_id`: The address (host, port) pair of the connection.
        N)rê   rù   r   r	  r   )r   rX   r   r  r   r   r   Ú publish_server_heartbeat_startedÛ  ó   

ÿýz0_EventListeners.publish_server_heartbeat_startedc              	   C   óB   t |||ƒ}| jD ]}z| |¡ W q	 ty   tƒ  Y q	w dS )a^  Publish a ServerHeartbeatSucceededEvent to all server heartbeat
        listeners.

        :Parameters:
         - `connection_id`: The address (host, port) pair of the connection.
         - `duration`: The execution time of the event in the highest possible
            resolution for the platform.
         - `reply`: The command reply.
         N)rë   rù   r   r	  r   ©r   rX   rw   rx   r   r  r   r   r   Ú"publish_server_heartbeat_succeededé  s   

ÿýz2_EventListeners.publish_server_heartbeat_succeededc              	   C   r  )a[  Publish a ServerHeartbeatFailedEvent to all server heartbeat
        listeners.

        :Parameters:
         - `connection_id`: The address (host, port) pair of the connection.
         - `duration`: The execution time of the event in the highest possible
            resolution for the platform.
         - `reply`: The command reply.
         N)ró   rù   r   r	  r   r  r   r   r   Úpublish_server_heartbeat_failedû  s   


ÿýz/_EventListeners.publish_server_heartbeat_failedc              	   C   ó@   t ||ƒ}| jD ]}z| |¡ W q ty   tƒ  Y qw dS )a  Publish a ServerOpeningEvent to all server listeners.

        :Parameters:
         - `server_address`: The address (host, port) pair of the server.
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)rÚ   rø   r.   r	  r   ©r   rÊ   rË   r   r  r   r   r   Úpublish_server_opened  ó   


ÿýz%_EventListeners.publish_server_openedc              	   C   r  )a  Publish a ServerClosedEvent to all server listeners.

        :Parameters:
         - `server_address`: The address (host, port) pair of the server.
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)rÜ   rø   r0   r	  r   r  r   r   r   Úpublish_server_closed  r  z%_EventListeners.publish_server_closedc              	   C   sD   t ||||ƒ}| jD ]}z| |¡ W q
 ty   tƒ  Y q
w dS )a‹  Publish a ServerDescriptionChangedEvent to all server listeners.

        :Parameters:
         - `previous_description`: The previous server description.
         - `server_address`: The address (host, port) pair of the server.
         - `new_description`: The new server description.
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)rÍ   rø   r/   r	  r   )r   rÕ   rÖ   rÊ   rË   r   r  r   r   r   Ú"publish_server_description_changed*  s   þ

ÿýz2_EventListeners.publish_server_description_changedc              	   C   r  )z»Publish a TopologyOpenedEvent to all topology listeners.

        :Parameters:
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)rå   rú   r.   r	  r   ©r   rË   r   r  r   r   r   Úpublish_topology_opened?  r  z'_EventListeners.publish_topology_openedc              	   C   r  )z»Publish a TopologyClosedEvent to all topology listeners.

        :Parameters:
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)ræ   rú   r0   r	  r   r  r   r   r   Úpublish_topology_closedM  r  z'_EventListeners.publish_topology_closedc              	   C   óB   t |||ƒ}| jD ]}z| |¡ W q	 ty   tƒ  Y q	w dS )aI  Publish a TopologyDescriptionChangedEvent to all topology listeners.

        :Parameters:
         - `previous_description`: The previous topology description.
         - `new_description`: The new topology description.
         - `topology_id`: A unique identifier for the topology this server
           is a part of.
        N)râ   rú   r/   r	  r   )r   rÕ   rÖ   rË   r   r  r   r   r   Ú$publish_topology_description_changed[  s   
ÿ

ÿýz4_EventListeners.publish_topology_description_changedc              	   C   r  )zCPublish a :class:`PoolCreatedEvent` to all pool listeners.
        N)r’   rû   r    r	  r   )r   r‰   r•   r   r  r   r   r   Úpublish_pool_createdm  ó   


ÿýz$_EventListeners.publish_pool_createdc              	   C   r  )zCPublish a :class:`PoolClearedEvent` to all pool listeners.
        N)r›   rû   r"   r	  r   ©r   r‰   r   r  r   r   r   Úpublish_pool_clearedw  ó   

ÿýz$_EventListeners.publish_pool_clearedc              	   C   r  )zBPublish a :class:`PoolClosedEvent` to all pool listeners.
        N)rž   rû   r#   r	  r   r$  r   r   r   Úpublish_pool_closed�  r&  z#_EventListeners.publish_pool_closedc              	   C   r  )zWPublish a :class:`ConnectionCreatedEvent` to all connection
        listeners.
        N)rµ   rû   r$   r	  r   ©r   r‰   rX   r   r  r   r   r   Úpublish_connection_created‹  ó   


ÿýz*_EventListeners.publish_connection_createdc              	   C   r  )zMPublish a :class:`ConnectionReadyEvent` to all connection listeners.
        N)r¶   rû   r%   r	  r   r(  r   r   r   Úpublish_connection_ready–  r#  z(_EventListeners.publish_connection_readyc              	   C   r   )zVPublish a :class:`ConnectionClosedEvent` to all connection
        listeners.
        N)r¸   rû   r'   r	  r   )r   r‰   rX   r»   r   r  r   r   r   Úpublish_connection_closed   s   

ÿýz)_EventListeners.publish_connection_closedc              	   C   r  )z_Publish a :class:`ConnectionCheckOutStartedEvent` to all connection
        listeners.
        N)r½   rû   r(   r	  r   r$  r   r   r   Ú$publish_connection_check_out_started«  s   

ÿýz4_EventListeners.publish_connection_check_out_startedc              	   C   r  )z^Publish a :class:`ConnectionCheckOutFailedEvent` to all connection
        listeners.
        N)rÀ   rû   r(   r	  r   )r   r‰   r»   r   r  r   r   r   Ú#publish_connection_check_out_failed¶  r*  z3_EventListeners.publish_connection_check_out_failedc              	   C   r  )zZPublish a :class:`ConnectionCheckedOutEvent` to all connection
        listeners.
        N)rÃ   rû   r*   r	  r   r(  r   r   r   Úpublish_connection_checked_outÁ  r*  z._EventListeners.publish_connection_checked_outc              	   C   r  )zYPublish a :class:`ConnectionCheckedInEvent` to all connection
        listeners.
        N)rÄ   rû   r+   r	  r   r(  r   r   r   Úpublish_connection_checked_inÌ  r*  z-_EventListeners.publish_connection_checked_inrQ   )"r   r   r   r   rZ   r_   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r!  r"  r%  r'  r)  r+  r,  r-  r.  r/  r0  r   r   r   r   rö   S  sN    





ÿ
ÿ
ÿ



rö   N)4r   Úcollectionsr   Úbson.py3compatr   Úpymongo.helpersr   Ú
_Listenersr@   Úobjectr   r   r   r,   r-   r3   r7   r?   rB   Úsetri   rL   ra   rr   r|   r‚   r’   r›   rž   rŸ   r¨   r®   rµ   r¶   r¸   r½   rÀ   rÃ   rÄ   rÅ   rÍ   rÚ   rÜ   rÞ   râ   rå   ræ   rç   rê   rë   ró   rö   r   r   r   r   Ú<module>   sh    %ÿ w"!!ÿ $# %					