
    _iA'                        d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZmZ  G d
 d          ZdS )zRepresent one server the driver is connected to.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
    )annotationsN)AnyMappingOptional)EPOCH_NAIVE)ObjectId)Hello)SERVER_TYPE)ClusterTime_Addressc                  *   e Zd ZU dZdZ	 	 	 	 dDdEdZedFd            ZedGd            ZedHd            Z	edId            Z
edJd            ZedKd            ZedLd            ZedGd            ZedGd             ZedGd!            ZedGd"            ZedGd#            ZedMd%            ZedNd'            ZedOd)            ZedPd+            ZedLd,            ZedMd-            ZedQd.            ZedRd/            ZedQd0            ZedRd1            ZedSd2            ZedTd4            ZedTd5            ZedTd6            Z edTd7            Z!edTd8            Z"edTd9            Z#edUd;            Z$dVdWd<Z%dXd?Z&dXd@Z'dHdAZ(i Z)dBe*dC<   dS )YServerDescriptionaR  Immutable representation of one server.

    :param address: A (host, port) pair
    :param hello: Optional Hello instance
    :param round_trip_time: Optional float
    :param error: Optional, the last error attempting to connect to the server
    :param round_trip_time: Optional float, the min latency from the most recent samples
    )_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_min_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_versionN        addressr   helloOptional[Hello[dict[str, Any]]]round_trip_timeOptional[float]errorOptional[Exception]min_round_trip_timefloatreturnNonec                8   || _         |st          i           }|j        | _        |j        | _        |j        | _        |j        | _	        |j
        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j         | _!        || _"        || _#        |j$        | _%        tM          j'                    | _(        || _)        |j*        | _+        |r@tY          |dd           }t[          |t\                    r|/                    d          | _+        |  |j0        r*|j0        tb          z
  }|2                                | _3        d S d | _3        d S )NdetailstopologyVersion)4r   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   r   mer   time	monotonicr%   r    topology_versionr&   getattr
isinstancedictgetlast_write_dater   total_secondsr$   )selfr(   r)   r+   r-   r/   r4   deltas           =D:\Nbitz\venv\Lib\site-packages\pymongo/server_description.py__init__zServerDescription.__init__E   s      	"IIE!-/Z
!&!7#1!&!7%*%?"!&!7!&!7!-!-"/!-!-#(#H  /$7!8!%!1!1!&!7 	HeY55G'4(( H)05F)G)G&.  	))K7E$)$7$7$9$9D!!!$(D!!!    c                    | j         S )z(The address (host, port) of this server.)r   rP   s    rR   r(   zServerDescription.addresst        }rT   intc                    | j         S )zThe type of this server.)r   rV   s    rR   r6   zServerDescription.server_typey   s       rT   strc                0    t           j        | j                 S )zSThe server type as a human readable string.

        .. versionadded:: 3.4
        )r
   _fieldsr   rV   s    rR   server_type_namez"ServerDescription.server_type_name~   s     "4#455rT   set[tuple[str, int]]c                    | j         S )z;List of hosts, passives, and arbiters known to this server.)r   rV   s    rR   r7   zServerDescription.all_hosts   s     rT   Mapping[str, Any]c                    | j         S N)r   rV   s    rR   r8   zServerDescription.tags   s
    zrT   Optional[str]c                    | j         S )zReplica set name or None.)r   rV   s    rR   r9   z"ServerDescription.replica_set_name   s     %%rT   Optional[tuple[str, int]]c                    | j         S )z8This server's opinion about who the primary is, or None.)r   rV   s    rR   r:   zServerDescription.primary   rW   rT   c                    | j         S rb   )r   rV   s    rR   r;   zServerDescription.max_bson_size   s    ""rT   c                    | j         S rb   )r   rV   s    rR   r<   z"ServerDescription.max_message_size       %%rT   c                    | j         S rb   )r   rV   s    rR   r=   z&ServerDescription.max_write_batch_size   s    ))rT   c                    | j         S rb   )r   rV   s    rR   r>   z"ServerDescription.min_wire_version   ri   rT   c                    | j         S rb   r   rV   s    rR   r?   z"ServerDescription.max_wire_version   ri   rT   Optional[int]c                    | j         S rb   )r!   rV   s    rR   r@   zServerDescription.set_version         rT   Optional[ObjectId]c                    | j         S rb   )r"   rV   s    rR   rA   zServerDescription.election_id   rp   rT   Optional[ClusterTime]c                    | j         S rb   )r#   rV   s    rR   rB   zServerDescription.cluster_time   s    !!rT   (tuple[Optional[int], Optional[ObjectId]]c                V    t          j        dt          d           | j        | j        fS )NzL'election_tuple' is deprecated, use  'set_version' and 'election_id' instead   )
stacklevel)warningswarnDeprecationWarningr!   r"   rV   s    rR   election_tuplez ServerDescription.election_tuple   s7    Z	
 	
 	
 	

  $"333rT   c                    | j         S rb   )r   rV   s    rR   rF   zServerDescription.me   s	    xrT   c                    | j         S rb   )r   rV   s    rR   rE   z1ServerDescription.logical_session_timeout_minutes   s    ''rT   c                    | j         S rb   )r$   rV   s    rR   rN   z!ServerDescription.last_write_date   s    $$rT   c                    | j         S rb   )r%   rV   s    rR   last_update_timez"ServerDescription.last_update_time   ri   rT   c                P    | j         | j        v r| j        | j                  S | j        S )z$The current average latency or None.)r   _host_to_round_trip_timer   rV   s    rR   r+   z!ServerDescription.round_trip_time   s-     =D9990??$$rT   c                    | j         S )z-The min latency from the most recent samples.)r   rV   s    rR   r/   z%ServerDescription.min_round_trip_time   s     ((rT   c                    | j         S )z<The last error attempting to connect to the server, or None.)r    rV   s    rR   r-   zServerDescription.error   s     {rT   boolc                    | j         S rb   )r   rV   s    rR   rC   zServerDescription.is_writable   rp   rT   c                    | j         S rb   )r   rV   s    rR   rD   zServerDescription.is_readable   rp   rT   c                ,    | j         t          j        k    S rb   )r   r
   MongosrV   s    rR   mongoszServerDescription.mongos   s     K$666rT   c                ,    | j         t          j        k    S rb   )r6   r
   UnknownrV   s    rR   is_server_type_knownz&ServerDescription.is_server_type_known   s    ;#666rT   c                j    | j         t          j        t          j        fv p| j         t          j        k    S )0Checks if this server supports retryable writes.)r   r
   r   	RSPrimaryLoadBalancerrV   s    rR   retryable_writes_supportedz,ServerDescription.retryable_writes_supported   s2     +"4k6K!LL;+"::	;rT   c                    | j         dk    S )r      rm   rV   s    rR   retryable_reads_supportedz+ServerDescription.retryable_reads_supported   s     %**rT   Optional[Mapping[str, Any]]c                    | j         S rb   )r&   rV   s    rR   rI   z"ServerDescription.topology_version  ri   rT   c                J    t          | j        |          }| j        |_        |S )N)r-   )r   r(   rI   r&   )rP   r-   unknowns      rR   
to_unknownzServerDescription.to_unknown  s&    #DL>>>$($9!rT   otherr   c                   t          |t                    r| j        |j        k    o| j        |j        k    o| j        |j        k    o| j        |j	        k    o| j
        |j        k    o| j        |j        k    oo| j        |j        k    o_| j        |j        k    oO| j        |j        k    o?| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S t8          S rb   )rK   r   r   r(   r   r6   r   r>   r   r?   r   rF   r   r7   r   r8   r   r9   r!   r@   r"   rA   r   r:   r   rE   r    r-   NotImplementedrP   r   s     rR   __eq__zServerDescription.__eq__
  s   e.// 	%-/ 1&%*;;1+u/EE1 +u/EE1 X)	1
 _71 Z5:-1 +u/EE1 &%*;;1 &%*;;1 ]em31 -1VV1 [EK/  rT   c                    | |k     S rb    r   s     rR   __ne__zServerDescription.__ne__  s    5=  rT   c                    d}| j         r
d| j         }d                    | j        j        | j        | j        | j        |          S )N z, error=z"<{} {} server_type: {}, rtt: {}{}>)r-   format	__class____name__r(   r]   r+   )rP   errmsgs     rR   __repr__zServerDescription.__repr__!  sT    : 	/.
..F3::N#L! 
 
 	
rT   rL   r   )NNNr'   )r(   r   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   )r1   r   )r1   rX   )r1   rZ   )r1   r^   )r1   r`   )r1   rc   )r1   re   )r1   rn   )r1   rq   )r1   rs   )r1   ru   )r1   r,   )r1   r0   )r1   r.   )r1   r   )r1   r   rb   )r-   r.   r1   r   )r   r   r1   r   )+r   
__module____qualname____doc__	__slots__rS   propertyr(   r6   r]   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   r|   rF   rE   rN   r   r+   r/   r-   rC   rD   r   r   r   r   rI   r   r   r   r   r   __annotations__r   rT   rR   r   r       st         I< 26+/%)%(-) -) -) -) -)^    X ! ! ! X! 6 6 6 X6    X    X & & & X&    X # # # X# & & & X& * * * X* & & & X& & & & X& ! ! ! X! ! ! ! X! " " " X" 4 4 4 X4    X ( ( ( X( % % % X% & & & X& % % % X% ) ) ) X)    X ! ! ! X! ! ! ! X! 7 7 7 X7 7 7 7 X7 ; ; ; X; + + + X+ & & & X&    
   (! ! ! !

 

 

 

 &(''''''rT   r   )r   
__future__r   rG   ry   typingr   r   r   bsonr   bson.objectidr   pymongo.hellor	   pymongo.server_typer
   pymongo.typingsr   r   r   r   rT   rR   <module>r      s     # " " " " "   ) ) ) ) ) ) ) ) ) )       " " " " " "       + + + + + + 1 1 1 1 1 1 1 1N( N( N( N( N( N( N( N( N( N(rT   