
    h                     N    d Z ddlmZ ddlmZ ddlmZ ddlmZ	  G d de
      Zy)	z0Represent one server the driver is connected to.    )EPOCH_NAIVE)SERVER_TYPE)IsMaster)timec                      e Zd ZdZdZ	 	 	 d&dZed        Zed        Zed        Z	ed        Z
ed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Z ed        Z!ed         Z"ed!        Z#d'd"Z$d# Z%d$ Z&d% Z'i Z(y)(ServerDescriptiona  Immutable representation of one server.

    :Parameters:
      - `address`: A (host, port) pair
      - `ismaster`: Optional IsMaster instance
      - `round_trip_time`: Optional float
      - `error`: Optional, the last error attempting to connect to the server
    )_address_server_type
_all_hosts_tags_replica_set_name_primary_max_bson_size_max_message_size_max_write_batch_size_min_wire_version_max_wire_version_round_trip_time_me_is_writable_is_readable_ls_timeout_minutes_error_set_version_election_id_cluster_time_last_write_date_last_update_time_topology_versionNc                    || _         |st        i       }|j                  | _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _        |j                  | _        |j                  | _        |j                   | _        |j$                  | _        |j(                  | _        |j,                  | _        |j0                  | _        |j4                  | _        |j8                  | _        |j<                  | _        |j@                  | _!        || _"        |jF                  | _$        tK               | _&        || _'        |jP                  | _)        |rFtU        |d      r:tW        |jX                  tZ              r |jX                  j]                  d      | _)        |j^                  r)|j^                  t`        z
  }|jc                         | _2        y d | _2        y )NdetailstopologyVersion)3r	   r   server_typer
   	all_hostsr   tagsr   replica_set_namer   primaryr   max_bson_sizer   max_message_sizer   max_write_batch_sizer   min_wire_versionr   max_wire_versionr   set_versionr   election_idr   cluster_timer   is_writabler   is_readabler   logical_session_timeout_minutesr   r   mer   _timer   r   topology_versionr   hasattr
isinstancer!   dictgetlast_write_dater   total_secondsr   )selfaddressismasterround_trip_timeerrordeltas         ]/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/pymongo/server_description.py__init__zServerDescription.__init__*   s     |H$00",,]]
!)!:!: ((&44!)!:!:%-%B%B"!)!:!:!)!:!:$00$00%22$00$00#+#K#K  /;;!&!)!:!:ui(Zt-L).):):;L)M&##,,{:E$)$7$7$9D!$(D!    c                     | j                   S )z(The address (host, port) of this server.)r	   r<   s    rB   r=   zServerDescription.addressT        }}rD   c                     | j                   S )zThe type of this server.)r
   rF   s    rB   r#   zServerDescription.server_typeY   s        rD   c                 <    t         j                  | j                     S )zSThe server type as a human readable string.

        .. versionadded:: 3.4
        )r   _fieldsr
   rF   s    rB   server_type_namez"ServerDescription.server_type_name^   s     ""4#4#455rD   c                     | j                   S )z;List of hosts, passives, and arbiters known to this server.)r   rF   s    rB   r$   zServerDescription.all_hostsf   s     rD   c                     | j                   S N)r   rF   s    rB   r%   zServerDescription.tagsk   s    zzrD   c                     | j                   S )zReplica set name or None.)r   rF   s    rB   r&   z"ServerDescription.replica_set_nameo   s     %%%rD   c                     | j                   S )z8This server's opinion about who the primary is, or None.)r   rF   s    rB   r'   zServerDescription.primaryt   rG   rD   c                     | j                   S rN   )r   rF   s    rB   r(   zServerDescription.max_bson_sizey   s    """rD   c                     | j                   S rN   )r   rF   s    rB   r)   z"ServerDescription.max_message_size}       %%%rD   c                     | j                   S rN   )r   rF   s    rB   r*   z&ServerDescription.max_write_batch_size   s    )))rD   c                     | j                   S rN   )r   rF   s    rB   r+   z"ServerDescription.min_wire_version   rS   rD   c                     | j                   S rN   r   rF   s    rB   r,   z"ServerDescription.max_wire_version   rS   rD   c                     | j                   S rN   )r   rF   s    rB   r-   zServerDescription.set_version          rD   c                     | j                   S rN   )r   rF   s    rB   r.   zServerDescription.election_id   rY   rD   c                     | j                   S rN   )r   rF   s    rB   r/   zServerDescription.cluster_time   s    !!!rD   c                 2    | j                   | j                  fS rN   )r   r   rF   s    rB   election_tuplez ServerDescription.election_tuple   s      $"3"333rD   c                     | j                   S rN   )r   rF   s    rB   r3   zServerDescription.me   s    xxrD   c                     | j                   S rN   )r   rF   s    rB   r2   z1ServerDescription.logical_session_timeout_minutes   s    '''rD   c                     | j                   S rN   )r   rF   s    rB   r:   z!ServerDescription.last_write_date   s    $$$rD   c                     | j                   S rN   )r   rF   s    rB   last_update_timez"ServerDescription.last_update_time   rS   rD   c                 |    | j                   | j                  v r| j                  | j                      S | j                  S )z$The current average latency or None.)r	   _host_to_round_trip_timer   rF   s    rB   r?   z!ServerDescription.round_trip_time   s7     ==D99900??$$$rD   c                     | j                   S )z<The last error attempting to connect to the server, or None.)r   rF   s    rB   r@   zServerDescription.error   s     {{rD   c                     | j                   S rN   )r   rF   s    rB   r0   zServerDescription.is_writable   rY   rD   c                     | j                   S rN   )r   rF   s    rB   r1   zServerDescription.is_readable   rY   rD   c                 <    | j                   t        j                  k(  S rN   )r
   r   MongosrF   s    rB   mongoszServerDescription.mongos   s      K$6$666rD   c                 <    | j                   t        j                  k7  S rN   )r#   r   UnknownrF   s    rB   is_server_type_knownz&ServerDescription.is_server_type_known   s    ;#6#666rD   c                 z    | j                   duxr, | j                  t        j                  t        j                  fv S )0Checks if this server supports retryable writes.N)r   r
   r   ri   	RSPrimaryrF   s    rB   retryable_writes_supportedz,ServerDescription.retryable_writes_supported   s=     $$D0 M+"4"4k6K6K!LL	NrD   c                      | j                   dk\  S )ro      rW   rF   s    rB   retryable_reads_supportedz+ServerDescription.retryable_reads_supported   s     %%**rD   c                     | j                   S rN   )r   rF   s    rB   r5   z"ServerDescription.topology_version   rS   rD   c                 V    t        | j                  |      }| j                  |_        |S )N)r@   )r   r=   r5   r   )r<   r@   unknowns      rB   
to_unknownzServerDescription.to_unknown   s%    #DLL>$($9$9!rD   c                    t        |t              r`| j                  |j                  k(  xrD | j                  |j
                  k(  xr( | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                   |j"                  k(  xr | j$                  |j&                  k(  xrj | j(                  |j*                  k(  xrO | j,                  |j.                  k(  xr4 | j0                  |j2                  k(  xr | j4                  |j6                  k(  S t8        S rN   )r7   r   r	   r=   r
   r#   r   r+   r   r,   r   r3   r   r$   r   r%   r   r&   r   r-   r   r.   r   r'   r   r2   r   r@   NotImplementedr<   others     rB   __eq__zServerDescription.__eq__   sY   e./]]emm3 1&&%*;*;;1++u/E/EE1 ++u/E/EE1 XX)	1
 __71 ZZ5::-1 ++u/E/EE1 &&%*;*;;1 &&%*;*;;1 ]]emm31 --::;1 [[EKK/2 rD   c                     | |k(   S rN    r{   s     rB   __ne__zServerDescription.__ne__   s    5=  rD   c           
          d}| j                   rd| j                   }d| j                  j                  d| j                  d| j                  d| j
                  |d
S )N z, error=< z server_type: z, rtt: >)r@   	__class____name__r=   rK   r?   )r<   errmsgs     rB   __repr__zServerDescription.__repr__   sK    ::%)ZZ1FNN##T\\43H3H  &* 	*rD   )NNNrN   ))r   
__module____qualname____doc__	__slots__rC   propertyr=   r#   rK   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r]   r3   r2   r:   rb   r?   r@   r0   r1   rj   rm   rq   rt   r5   rx   r}   r   r   rd   r   rD   rB   r   r      s   I  ()T   ! ! 6 6     & &   # # & & * * & & & & ! ! ! ! " " 4 4   ( ( % % & & % %   ! ! ! ! 7 7 7 7 N N + + & &
&!*  "rD   r   N)r   bsonr   pymongo.server_typer   pymongo.ismasterr   pymongo.monotonicr   r4   objectr   r   rD   rB   <module>r      s$    7  + % +h" h"rD   