o
    Åîï]¿  ã                   @   sH   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„ de
ƒZdS )	z0Represent one server the driver is connected to.é    )ÚEPOCH_NAIVE)ÚSERVER_TYPE)ÚIsMaster)Útimec                   @   sx  e Zd ZdZdZ			d>dd„Zedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZed"d#„ ƒZed$d%„ ƒZed&d'„ ƒZed(d)„ ƒZed*d+„ ƒZed,d-„ ƒZed.d/„ ƒZed0d1„ ƒZed2d3„ ƒZed4d5„ ƒZed6d7„ ƒZed8d9„ ƒZ ed:d;„ ƒZ!ed<d=„ ƒZ"i Z#dS )?Ú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_timeNc                 C   sÖ   || _ |s	ti ƒ}|j| _|j| _|j| _|j| _	|j
| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j | _!|| _"|j#| _$t%ƒ | _&|| _'|j(rf|j(t) }| *¡ | _+d S d | _+d S ©N),r   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   Úlast_write_dater   Útotal_secondsr   )ÚselfÚaddressÚismasterÚround_trip_timeÚerrorÚdelta© r8   úL/var/www/html/env/lib/python3.10/site-packages/pymongo/server_description.pyÚ__init__)   s6   

zServerDescription.__init__c                 C   ó   | j S )z(The address (host, port) of this server.)r   ©r2   r8   r8   r9   r3   O   ó   zServerDescription.addressc                 C   r;   )zThe type of this server.)r   r<   r8   r8   r9   r   T   r=   zServerDescription.server_typec                 C   s   t j| j S )zSThe server type as a human readable string.

        .. versionadded:: 3.4
        )r   Ú_fieldsr   r<   r8   r8   r9   Úserver_type_nameY   s   z"ServerDescription.server_type_namec                 C   r;   )z;List of hosts, passives, and arbiters known to this server.)r	   r<   r8   r8   r9   r   a   r=   zServerDescription.all_hostsc                 C   r;   r   )r
   r<   r8   r8   r9   r    f   ó   zServerDescription.tagsc                 C   r;   )zReplica set name or None.)r   r<   r8   r8   r9   r!   j   r=   z"ServerDescription.replica_set_namec                 C   r;   )z8This server's opinion about who the primary is, or None.)r   r<   r8   r8   r9   r"   o   r=   zServerDescription.primaryc                 C   r;   r   )r   r<   r8   r8   r9   r#   t   r@   zServerDescription.max_bson_sizec                 C   r;   r   )r   r<   r8   r8   r9   r$   x   r@   z"ServerDescription.max_message_sizec                 C   r;   r   )r   r<   r8   r8   r9   r%   |   r@   z&ServerDescription.max_write_batch_sizec                 C   r;   r   )r   r<   r8   r8   r9   r&   €   r@   z"ServerDescription.min_wire_versionc                 C   r;   r   ©r   r<   r8   r8   r9   r'   „   r@   z"ServerDescription.max_wire_versionc                 C   r;   r   )r   r<   r8   r8   r9   r(   ˆ   r@   zServerDescription.set_versionc                 C   r;   r   )r   r<   r8   r8   r9   r)   Œ   r@   zServerDescription.election_idc                 C   r;   r   )r   r<   r8   r8   r9   r*   �   r@   zServerDescription.cluster_timec                 C   s   | j | jfS r   )r   r   r<   r8   r8   r9   Úelection_tuple”   ó   z ServerDescription.election_tuplec                 C   r;   r   )r   r<   r8   r8   r9   r.   ˜   r@   zServerDescription.mec                 C   r;   r   )r   r<   r8   r8   r9   r-   œ   r@   z1ServerDescription.logical_session_timeout_minutesc                 C   r;   r   )r   r<   r8   r8   r9   r0       r@   z!ServerDescription.last_write_datec                 C   r;   r   )r   r<   r8   r8   r9   Úlast_update_time¤   r@   z"ServerDescription.last_update_timec                 C   s   | j | jv r| j| j  S | jS )z$The current average latency or None.)r   Ú_host_to_round_trip_timer   r<   r8   r8   r9   r5   ¨   s   z!ServerDescription.round_trip_timec                 C   r;   )z<The last error attempting to connect to the server, or None.)r   r<   r8   r8   r9   r6   ±   r=   zServerDescription.errorc                 C   r;   r   )r   r<   r8   r8   r9   r+   ¶   r@   zServerDescription.is_writablec                 C   r;   r   )r   r<   r8   r8   r9   r,   º   r@   zServerDescription.is_readablec                 C   s   | j tjkS r   )r   r   ÚMongosr<   r8   r8   r9   Úmongos¾   rC   zServerDescription.mongosc                 C   s   | j tjkS r   )r   r   ÚUnknownr<   r8   r8   r9   Úis_server_type_knownÂ   rC   z&ServerDescription.is_server_type_knownc                 C   s   | j duo| jtjtjfv S )ú0Checks if this server supports retryable writes.N)r   r   r   rF   Ú	RSPrimaryr<   r8   r8   r9   Úretryable_writes_supportedÆ   s   
þz,ServerDescription.retryable_writes_supportedc                 C   s
   | j dkS )rJ   é   rA   r<   r8   r8   r9   Úretryable_reads_supportedÍ   s   
z+ServerDescription.retryable_reads_supported)NNN)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r:   Úpropertyr3   r   r?   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   rB   r.   r-   r0   rD   r5   r6   r+   r,   rG   rI   rL   rN   rE   r8   r8   r8   r9   r      s€    	
û&



























r   N)rR   Úbsonr   Úpymongo.server_typer   Úpymongo.ismasterr   Úpymongo.monotonicr   r/   Úobjectr   r8   r8   r8   r9   Ú<module>   s   