o Sbp#@s|dZddlZddlmZmZmZmZmZmZddl m Z ddl m Z ddl mZddlmZddlmZGd d d eZdS) z0Represent one server the driver is connected to.N)AnyDictMappingOptionalSetTuple) EPOCH_NAIVE)ObjectId)Hello) SERVER_TYPE)_Addressc @seZdZUdZdZ   dOdedeedeedee ddf d d Z e defd d Z e de fd dZe defddZe deeee ffddZe deeeffddZe deefddZe deeee ffddZe de fddZe de fddZe de fddZe de fdd Ze de fd!d"Ze dee fd#d$Ze deefd%d&Z e deeeeffd'd(Z!e deee eeffd)d*Z"e deeee ffd+d,Z#e dee fd-d.Z$e deefd/d0Z%e defd1d2Z&e deefd3d4Z'e dee fd5d6Z(e de)fd7d8Z*e de)fd9d:Z+e de)fd;d<Z,e de)fd=d>Z-e de)fd?d@Z.e de)fdAdBZ/e deeeeffdCdDZ0dPdee ddfdEdFZ1dGede)fdHdIZ2dGede)fdJdKZ3dLdMZ4iZ5e6e7dN<dS)QServerDescriptionaImmutable representation of one server. :Parameters: - `address`: A (host, port) pair - `hello`: Optional Hello 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_versionNaddresshelloround_trip_timeerrorreturncCs ||_|s ti}|j|_|j|_|j|_|j|_ |j |_ |j |_ |j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j |_!||_"|j#|_$t%&|_'||_(|j)|_*|rot+|dd}t,|t-ro|.d|_*||j/r|j/t0}|1|_2dSd|_2dS)NdetailsZtopologyVersion)3rr server_typer all_hostsrtagsrreplica_set_namerprimaryr max_bson_sizermax_message_sizermax_write_batch_sizermin_wire_versionrmax_wire_versionr set_versionr election_idr cluster_timer! is_writabler is_readablerlogical_session_timeout_minutesrrmertime monotonicr#rtopology_versionr$getattr isinstancedictgetlast_write_dater total_secondsr")selfr%r&r'r(r*deltarGA/tmp/pip-target-onvjaxws/lib/python/pymongo/server_description.py__init__?sB      zServerDescription.__init__cC|jS)z(The address (host, port) of this server.)rrErGrGrHr%lzServerDescription.addresscCrJ)zThe type of this server.)rrKrGrGrHr+qrLzServerDescription.server_typecCs tj|jS)zSThe server type as a human readable string. .. versionadded:: 3.4 )r _fieldsrrKrGrGrHserver_type_namevs z"ServerDescription.server_type_namecCrJ)z;List of hosts, passives, and arbiters known to this server.)rrKrGrGrHr,~rLzServerDescription.all_hostscCrJN)rrKrGrGrHr-zServerDescription.tagscCrJ)zReplica set name or None.)rrKrGrGrHr.rLz"ServerDescription.replica_set_namecCrJ)z8This server's opinion about who the primary is, or None.)rrKrGrGrHr/rLzServerDescription.primarycCrJrO)rrKrGrGrHr0rPzServerDescription.max_bson_sizecCrJrO)rrKrGrGrHr1rPz"ServerDescription.max_message_sizecCrJrO)rrKrGrGrHr2rPz&ServerDescription.max_write_batch_sizecCrJrO)rrKrGrGrHr3rPz"ServerDescription.min_wire_versioncCrJrOrrKrGrGrHr4rPz"ServerDescription.max_wire_versioncCrJrO)rrKrGrGrHr5rPzServerDescription.set_versioncCrJrO)r rKrGrGrHr6rPzServerDescription.election_idcCrJrO)r!rKrGrGrHr7rPzServerDescription.cluster_timecCs |j|jfSrO)rr rKrGrGrHelection_tuple z ServerDescription.election_tuplecCrJrO)rrKrGrGrHr;rPzServerDescription.mecCrJrO)rrKrGrGrHr:rPz1ServerDescription.logical_session_timeout_minutescCrJrO)r"rKrGrGrHrCrPz!ServerDescription.last_write_datecCrJrO)r#rKrGrGrHlast_update_timerPz"ServerDescription.last_update_timecCs|j|jvr |j|jS|jS)z$The current average latency or None.)r_host_to_round_trip_timerrKrGrGrHr's  z!ServerDescription.round_trip_timecCrJ)zrPz"ServerDescription.topology_versioncCst|j|d}|j|_|S)N)r()r r%r>r$)rEr(unknownrGrGrH to_unknownszServerDescription.to_unknownothercCst|trS|j|jkoR|j|jkoR|j|jkoR|j|j koR|j |j koR|j |j koR|j|jkoR|j|jkoR|j|jkoR|j|jkoR|j|jkoR|j|jkoR|j|jkStSrO)r@r rr%rr+rr3rr4rr;rr,rr-rr.rr5r r6rr/rr:rr(NotImplementedrEr`rGrGrH__eq__s6              zServerDescription.__eq__cCs ||k SrOrGrbrGrGrH__ne__ s zServerDescription.__ne__cCs2d}|jr d|jf}d|jj|j|j|j|fS)Nz , error=%rz"<%s %s server_type: %s, rtt: %s%s>)r( __class____name__r%rNr')rEerrmsgrGrGrH__repr__s zServerDescription.__repr__rU)NNNrO)8rg __module__ __qualname____doc__ __slots__r rr float ExceptionrIpropertyr%intr+strrNrrr,rrr-r.r/r0r1r2r3r4r5r r6r7rRr;r:rCrTr'r(boolr8r9rWrYr[r]r>r_rcrdrirUr__annotations__rGrGrGrHr s   -  r )rlr<typingrrrrrrZbsonrZ bson.objectidr Z pymongo.hellor Zpymongo.server_typer Zpymongo.typingsr objectr rGrGrGrHs