+
    8iSt              
        a  0 t $ R t^ RIHt ^ RIHt ^ RIHtHtH	t	H
t
HtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHtHtHt ^ R	IHt ^ R
IH t  ^ RI!H"t" ^ RI#H$t$  ! R R]4      t%]%! ]&! ^4      !  t']'PP                  ]'PR                  3t*R]+R&   ]]	],          .]	],          3,          t, ! R R4      t-]"P\                  ]'PR                  ]"P^                  ]'P`                  ]"Pb                  ]'Pd                  ]"Pf                  ]'Pd                  ]"Ph                  ]'Pd                  /t5R R lt6R R lt7R R lt8R R lt9R R lt:R R lt;R# ) zRepresent a deployment of MongoDB servers.

.. seealso:: This module is compatible with both the synchronous and asynchronous PyMongo APIs.
)annotations)sample)AnyCallableListMappingMutableMapping
NamedTupleOptionalcastMinKey)ObjectId)common)ConfigurationErrorPyMongoError)PrimaryReadPreference_AggWritePref_ServerMode)ServerDescription)	Selection)SERVER_TYPE)_Addressc                  T    ] tR t^-t$ R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   RtR	# )
_TopologyTypeintSingleReplicaSetNoPrimaryReplicaSetWithPrimaryShardedUnknownLoadBalanced N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r#       Z/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymongo/topology_description.pyr   r   -   s#    KLLr*   r   ztuple[int, int]SRV_POLLING_TOPOLOGIESc                     ] tR t^?tR R ltR R ltR R ltR R ltR	 R
 ltR R lt	R R lt
]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R  l4       t]R! R" l4       t]R# R$ l4       t]R% R& l4       t]R' R( l4       tR) R* ltR7R, R- lltR8R. R/ llt]P:                  3R0 R1 lltR2 R3 ltR4 R5 lt R6t!R+# )9TopologyDescriptionc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )   topology_typer   server_descriptions!dict[_Address, ServerDescription]replica_set_nameOptional[str]max_set_versionOptional[int]max_election_idOptional[ObjectId]topology_settingsr   returnNoner#   )formats   "r+   __annotate__ TopologyDescription.__annotate__@   sP     1 11 ?1 (	1
 '1 ,1 1 
1r*   c                   Wn         W0n        W n        W@n        WPn        \        V P                  P                  4       4      V n        W`n        RV n	        V P                   \        P                  8w  d   V P                  4        V P                  pV'       g
   RV n        R# \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d
   RV n        R# \!        R V 4       4      V n        R# )a  Representation of a deployment of MongoDB servers.

:param topology_type: initial type
:param server_descriptions: dict of (address, ServerDescription) for
    all seeds
:param replica_set_name: replica set name or None
:param max_set_version: greatest setVersion seen from a primary, or None
:param max_election_id: greatest electionId seen from a primary, or None
:param topology_settings: a TopologySettings
Nc              3  <   "   T F  qP                   R J x  K  	  R # 5iNlogical_session_timeout_minutes.0ss   & r+   	<genexpr>/TopologyDescription.__init__.<locals>.<genexpr>l   s     UDTq22d:DTs   TFc              3  8   "   T F  qP                   x  K  	  R # 5irB   rC   rE   s   & r+   rH   rI   o   s      +;Ka11;K   )_topology_type_replica_set_name_server_descriptions_max_set_version_max_election_idlistvalues_candidate_servers_topology_settings_incompatible_errTOPOLOGY_TYPEr"   _init_incompatible_errreadable_servers_ls_timeout_minutesanymin)selfr1   r2   r4   r6   r8   r:   rX   s   &&&&&&& r+   __init__TopologyDescription.__init__@   s    & ,!1$7! / /"&t'@'@'G'G'I"J #4 "&-"<"<<'')  00'+D$SUDTUSSSUDTUUU'+D$'* +;K+ (D$r*   c                   V ^8  d   QhRR/# r0   r;   r<   r#   )r=   s   "r+   r>   r?   s   s     - - -r*   c                   V P                   P                  4        EFM  pVP                  '       g   K  VP                  RJ;'       d    VP                  \        P
                  8  pVP                  RJ;'       d    VP                  \        P                  8  pV'       dY   RVP                  ^ ,          VP                  ^,          ;'       g    ^ VP                  \        P
                  3,          V n	        K  V'       g   K  RVP                  ^ ,          VP                  ^,          ;'       g    ^ VP                  \        P                  \        P                  3,          V n	         R# 	  R# )z>Internal compatibility check for non-load balanced topologies.Nz]Server at %s:%d requires wire version %d, but this version of PyMongo only supports up to %d.zgServer at %s:%d reports wire version %d, but this version of PyMongo requires at least %d (MongoDB %s).)rN   rR   is_server_type_knownmin_wire_versionr   MAX_SUPPORTED_WIRE_VERSIONmax_wire_versionMIN_SUPPORTED_WIRE_VERSIONaddressrU   MIN_SUPPORTED_SERVER_VERSION)r\   rG   server_too_newserver_too_olds   &   r+   rW   *TopologyDescription._init_incompatible_errs   sC   **113A))) ""$. K K&&)J)JJ  ""$. K K&&)J)JJ  A 		!		!))**99	 &  L 		!		!))**99;; & W 4r*   c                   V ^8  d   QhRR/# r`   r#   )r=   s   "r+   r>   r?      s     = =$ =r*   c                T    V P                   '       d   \        V P                   4      hR# )zRaise ConfigurationError if any server is incompatible.

A server is incompatible if its wire protocol version range does not
overlap with PyMongo's.
N)rU   r   r\   s   &r+   check_compatible$TopologyDescription.check_compatible   s&     !!!$T%;%;<< "r*   c                    V ^8  d   QhRRRR/# )r0   rg   r   r;   boolr#   )r=   s   "r+   r>   r?      s     4 4( 4t 4r*   c                	    WP                   9   # rB   )rN   )r\   rg   s   &&r+   
has_serverTopologyDescription.has_server   s    3333r*   c                    V ^8  d   QhRRRR/# )r0   rg   r   r;   r.   r#   )r=   s   "r+   r>   r?      s     > >H >1D >r*   c                Z    V P                   V,          P                  4       p\        W4      # )z;A copy of this description, with one server marked Unknown.)rN   
to_unknownupdated_topology_description)r\   rg   
unknown_sds   && r+   reset_server TopologyDescription.reset_server   s&    ..w7BBD
+D==r*   c                   V ^8  d   QhRR/# )r0   r;   r.   r#   )r=   s   "r+   r>   r?      s     
 
* 
r*   c                <   V P                   \        P                  8X  d   \        P                  pMV P                   pV P                   Uu/ uF  q"\        V4      bK  	  pp\        VVV P                  V P                  V P                  V P                  4      # u upi )z<A copy of this description, with all servers marked Unknown.)rL   rV   r   r   rN   r   r.   rM   rO   rP   rT   )r\   r1   rg   sdss   &   r+   resetTopologyDescription.reset   s    -"E"EE)==M //M CGB[B[\B[w)'22B[\"""!!!!##
 	
 ]s   Bc                   V ^8  d   QhRR/# )r0   r;   r3   r#   )r=   s   "r+   r>   r?      s     0 0%F 0r*   c                6    V P                   P                  4       # )zKdict of (address,
:class:`~pymongo.server_description.ServerDescription`).
)rN   copyrn   s   &r+   r2   'TopologyDescription.server_descriptions   s     ((--//r*   c                   V ^8  d   QhRR/# r0   r;   r   r#   )r=   s   "r+   r>   r?      s     # #s #r*   c                    V P                   # )zThe type of this topology.)rL   rn   s   &r+   r1   !TopologyDescription.topology_type   s     """r*   c                   V ^8  d   QhRR/# r0   r;   strr#   )r=   s   "r+   r>   r?      s     : :C :r*   c                D    \         P                  V P                  ,          # )zEThe topology type as a human readable string.

.. versionadded:: 3.4
)rV   _fieldsrL   rn   s   &r+   topology_type_name&TopologyDescription.topology_type_name   s     $$T%8%899r*   c                   V ^8  d   QhRR/# )r0   r;   r5   r#   )r=   s   "r+   r>   r?      s     & &- &r*   c                    V P                   # )zThe replica set name.)rM   rn   s   &r+   r4   $TopologyDescription.replica_set_name   s     %%%r*   c                   V ^8  d   QhRR/# r0   r;   r7   r#   )r=   s   "r+   r>   r?      s     % % %r*   c                    V P                   # )z1Greatest setVersion seen from a primary, or None.)rO   rn   s   &r+   r6   #TopologyDescription.max_set_version        $$$r*   c                   V ^8  d   QhRR/# )r0   r;   r9   r#   )r=   s   "r+   r>   r?      s     % %!3 %r*   c                    V P                   # )z1Greatest electionId seen from a primary, or None.)rP   rn   s   &r+   r8   #TopologyDescription.max_election_id   r   r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?      s     ( ( (r*   c                    V P                   # )z)Minimum logical session timeout, or None.)rY   rn   s   &r+   rD   3TopologyDescription.logical_session_timeout_minutes   s     '''r*   c                   V ^8  d   QhRR/# r0   r;   list[ServerDescription]r#   )r=   s   "r+   r>   r?      s     Y Y6 Yr*   c                    V P                   P                  4        Uu. uF  qP                  '       g   K  VNK  	  up# u upi )z)List of Servers of types besides Unknown.)rN   rR   rb   r\   rG   s   & r+   known_servers!TopologyDescription.known_servers   s5      44;;=X=aAWAW=XXX   >>c                   V ^8  d   QhRR/# r0   r;   rr   r#   )r=   s   "r+   r>   r?      s     \ \4 \r*   c                    \         ;QJ d4    R V P                  P                  4        4       F  '       g   K   R# 	  R# ! R V P                  P                  4        4       4      # )z7Whether there are any Servers of types besides Unknown.c              3  L   "   T F  qP                   '       g   K  Vx  K  	  R # 5irB   )rb   rE   s   & r+   rH   8TopologyDescription.has_known_servers.<locals>.<genexpr>   s     [@DZDZ11@s   $
$TF)rZ   rN   rR   rn   s   &r+   has_known_servers%TopologyDescription.has_known_servers   sK     s[d77>>@[ss[s[s[d77>>@[[[r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?      s     P P"9 Pr*   c                    V P                   P                  4        Uu. uF  qP                  '       g   K  VNK  	  up# u upi )zList of readable Servers.)rN   rR   is_readabler   s   & r+   rX   $TopologyDescription.readable_servers   s3      44;;=O=a=OOOr   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?      s     ' '#: 'r*   c                    V P                   # )z0List of Servers excluding deprioritized servers.)rS   rn   s   &r+   candidate_servers%TopologyDescription.candidate_servers   s     &&&r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?     s      ] r*   c                f    V P                   pV'       d   \        R V P                    4       4      # R# )z3Minimum of all servers' max wire versions, or None.c              3  8   "   T F  qP                   x  K  	  R # 5irB   )re   rE   s   & r+   rH   :TopologyDescription.common_wire_version.<locals>.<genexpr>  s     F3Ea))3ErK   N)r   r[   r\   serverss   & r+   common_wire_version'TopologyDescription.common_wire_version  s,     $$F43E3EFFFr*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?     s     ; ;S ;r*   c                	.    V P                   P                  # rB   )rT   heartbeat_frequencyrn   s   &r+   r   'TopologyDescription.heartbeat_frequency
  s    &&:::r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?     s     6 6s 6r*   c                	.    V P                   P                  # rB   )rT   _srv_max_hostsrn   s   &r+   srv_max_hosts!TopologyDescription.srv_max_hosts  s    &&555r*   c                    V ^8  d   QhRRRR/# )r0   	selectionzOptional[Selection]r;   r   r#   )r=   s   "r+   r>   r?     s     
 
0C 
H_ 
r*   c                	   V'       g   . # . pVP                    FV  pVP                  f+   RVP                   RV  RVP                    2p\        V4      hVP	                  VP                  4       KX  	  \        V4      pV P                  P                  R,          pVP                    Uu. uF-  p\        \        VP                  4      V,
          V8:  g   K+  VNK/  	  up# u upi )Nzround_trip_time for server z is unexpectedly None: z, servers: g     @@)
r2   round_trip_timerg   r   appendr[   rT   local_threshold_msr   float)r\   r   round_trip_timesserverconfig_err_msgfastest	thresholdrG   s   &&      r+   _apply_local_threshold*TopologyDescription._apply_local_threshold  s    I(*33F%%-#>v~~>NNefjekkv  xA  xU  xU  wV  "W(88##F$:$:;	 4 &'++>>G	 22
2UA--.8YF A2
 	
 
s   )(CCNc                    V ^8  d   QhRRRR/# )r0   deprioritized_servers!Optional[list[ServerDescription]]r;   r<   r#   )r=   s   "r+   r>   r?   $  s      E E%FE	Er*   c                   V'       g   V P                   V n        R# V Uu0 uF  q"P                  kK  	  ppV P                    Uu. uF  pVP                  V9  g   K  VNK  	  ppT;'       g    V P                   V n        R# u upi u upi )zBFilter out deprioritized servers from a list of server candidates.N)r   rS   rg   )r\   r   sddeprioritized_addressesr   filtereds   &&    r+   _filter_servers#TopologyDescription._filter_servers$  s     %&*&8&8D#<Q&R<Qbzz<Q#&R #000F>>)@@ 0  
 '/&D&D$2D2DD# 'Ss   BBBc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r0   selectorr   rg   zOptional[_Address]custom_selectorzOptional[_ServerSelector]r   r   r;   r   r#   )r=   s   "r+   r>   r?   3  sD     M6 M6M6 $M6 3	M6
  AM6 
!M6r*   c                \   \        VR^ 4      '       dC   V P                  pV'       d/   WQP                  8  d   \        RWP                  V3,          4      h\	        V\
        4      '       d   VP                  V 4       V P                  \        P                  8X  d   . # V P                  \        P                  \        P                  39   d   V P                  # V'       d?   V P                  4       P                  V4      pV'       d   VP                  '       d   V.# . # V P!                  V4       V P                  \        P"                  8X  d   \%        V4      \&        J d   V P(                   F9  pVP*                  \,        P.                  8X  g   K$  V.pV'       d	   V! V4      pVu # 	  V'       d@   V F9  pVP*                  \,        P.                  8X  g   K$  V.pV'       d	   V! V4      pVu # 	  . # \0        P2                  ! V 4      p	V P                  \        P4                  8w  dH   V! V	4      p	V	'       g8   V'       d0   V P!                  R4       \0        P2                  ! V 4      p	V! V	4      p	Ve*   V	'       d"   V	P7                  V! V	P                  4      4      p	V P9                  V	4      # )aD  List of servers matching the provided selector(s).

:param selector: a callable that takes a Selection as input and returns
    a Selection as output. For example, an instance of a read
    preference from :mod:`~pymongo.read_preferences`.
:param address: A server address to select.
:param custom_selector: A callable that augments server
    selection rules. Accepts a list of
    :class:`~pymongo.server_description.ServerDescription` objects and
    return a list of server descriptions that should be considered
    suitable for the desired operation.

.. versionadded:: 3.4
rc   zF%s requires min wire version %d, but topology's min wire version is %dN)getattrr   rc   r   
isinstancer   selection_hookr1   rV   r!   r   r"   r   r2   getrb   r   r   typer   rS   server_typer   	RSPrimaryr   from_topology_descriptionr    with_server_descriptionsr   )
r\   r   rg   r   r   	common_wvdescriptionr   r   r   s
   &&&&&     r+   apply_selector"TopologyDescription.apply_selector3  s.   * 8/3300IY)B)BB(*-57P7PR[,\] 
 h..##D)!6!66IM$8$8-:T:T#UU%%%22488AK$/K4T4T4TK=\Z\\23!D!DDh[bIb-->>[%:%::$C&-c2J . %/B~~)>)>>!d*"1#"6C"
 0 I77=	!6!66 +I!6$$T*%??E	$Y/	 &9!::	 = =>I **955r*   c                    V ^8  d   QhRRRR/# )r0   read_preferencer   r;   rr   r#   )r=   s   "r+   r>   r?     s     9 9; 9\` 9r*   c                d    \         P                  ! RV4       \        V P                  V4      4      # )a~  Does this topology have any readable servers available matching the
given read preference?

:param read_preference: an instance of a read preference from
    :mod:`~pymongo.read_preferences`. Defaults to
    :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.

.. note:: When connected directly to a single server this method
  always returns ``True``.

.. versionadded:: 3.4
r   )r   validate_read_preferencerZ   r   )r\   r   s   &&r+   has_readable_server'TopologyDescription.has_readable_server  s+     	''(9?K4&&788r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?     s     @ @T @r*   c                @    V P                  \        P                  4      # )zDoes this topology have a writable server available?

.. note:: When connected directly to a single server this method
  always returns ``True``.

.. versionadded:: 3.4
)r   r   PRIMARYrn   s   &r+   has_writable_server'TopologyDescription.has_writable_server  s     ''(>(>??r*   c                   V ^8  d   QhRR/# r   r#   )r=   s   "r+   r>   r?     s     
 
# 
r*   c                	    \        V P                  P                  4       R  R7      pRP                  V P                  P
                  V P                  P                  V P                  V4      # )c                    V P                   # rB   )rg   )r   s   &r+   <lambda>.TopologyDescription.__repr__.<locals>.<lambda>  s    BJJr*   )keyz-<{} id: {}, topology_type: {}, servers: {!r}>)	sortedrN   rR   r=   	__class__r$   rT   _topology_idr   r   s   & r+   __repr__TopologyDescription.__repr__  sY    2299;AVW>EENN####00##	
 	
r*   )	rS   rU   rY   rP   rO   rM   rN   rT   rL   rB   )NNN)"r$   r%   r&   r'   r]   rW   ro   rt   r{   r   r2   propertyr1   r   r4   r6   r8   rD   r   r   rX   r   r   r   r   r   r   r   r   r   r   r   r  r)   r#   r*   r+   r.   r.   ?   se   1f-^=4>

&0 # # : : & & % % % % ( ( Y Y \ \ P P ' '   ; ; 6 6
$EM6^ BPAWAW 9 @
 
r*   r.   c               $    V ^8  d   QhRRRRRR/# )r0   topology_descriptionr.   server_descriptionr   r;   r#   )r=   s   "r+   r>   r>     s)     e e-eCTeer*   c                    VP                   pV P                  pV P                  pV P                  pV P                  pVP
                  pV P                  4       pWV&   V\        P                  8X  du   VeI   WAP                  8w  d9   \        RP                  WAP                  4      4      p	VP                  V	R7      W&   \        \        P                  VVVVV P                  4      # V\        P                  8X  d   V\        P                   \        P"                  39   dH   \%        V P                  P&                  4      ^8X  d   \        P                  pMDVP)                  V4       M2V\        P                  \        P*                  39  d   \,        V,          pV\        P.                  8X  d9   V\        P0                  \        P                  39  d   VP)                  V4       EMV\        P2                  8X  d   V\        P                   \        P0                  39   d   VP)                  V4       EM3V\        P4                  8X  d   \7        WWV4      w  r4rVEMV\        P8                  \        P:                  \        P<                  39   d   \?        WV4      w  r4MV\        P@                  8X  d   V\        P                   \        P0                  39   d   VP)                  V4       \C        V4      pMrV\        P4                  8X  d   \7        WWV4      w  r4rVMLV\        P8                  \        P:                  \        P<                  39   d   \E        WV4      pM\C        V4      p\        VVVVVV P                  4      # )aV  Return an updated copy of a TopologyDescription.

:param topology_description: the current TopologyDescription
:param server_description: a new ServerDescription that resulted from
    a hello call

Called after attempting (successfully or not) to call hello on the
server at server_description.address. Does not modify topology_description.
zeclient is configured to connect to a replica set named '{}' but this node belongs to a set named '{}')error)#rg   r1   r4   r6   r8   r   r2   rV   r   r   r=   rx   r.   rT   r!   r   
StandaloneLoadBalancerlenseedspopRSGhost_SERVER_TYPE_TO_TOPOLOGY_TYPEr    Mongosr   r   _update_rs_from_primaryRSSecondary	RSArbiterRSOther!_update_rs_no_primary_from_memberr   _check_has_primary#_update_rs_with_primary_from_member)
r  r  rg   r1   set_namer6   r8   r   r   r
  s
   &&        r+   ry   ry     s    !((G )66M#44H*::O*::O$00K 
2
2
4C &L,,,H0S0S$S&AAGAABE .88u8ECL"   33
 	
 ---;11;3K3KLL'::@@AQF - 4 4  !4!4k6I6I JJ9+FM---{11;3F3FGGGGG	-;;	;;11;3E3EFFGGGK111Ja1OKG]o [44k6K6K[M`M`aa&G1'#M 
-==	=;11;3E3EFFGGG.s3MK111Ja1OKG]o [44k6K6K[M`M`aa?OabM /s3M // r*   c               $    V ^8  d   QhRRRRRR/# )r0   r  r.   seedlistzlist[tuple[str, Any]]r;   r#   )r=   s   "r+   r>   r>     s$     ( (-(9N((r*   c           	        V P                   \        9   g   Q hV P                  4       p\        VP	                  4       4      \        V4      8X  d   V # \        VP	                  4       4       F  pW19  g   K  VP                  V4       K  	  V P                  ^ 8w  dx   \        V4      \        VP	                  4       4      ,
          pV P                  \        V4      ,
          pV^ 8  d*   \        \        V4      \        V\        V4      4      4      pM. pV F  pW29  g   K  \        V4      W#&   K  	  \        V P                   VV P                  V P                  V P                   V P"                  4      # )zReturn an updated copy of a TopologyDescription.

:param topology_description: the current TopologyDescription
:param seedlist: a list of new seeds new ServerDescription that resulted from
    a hello call
)r1   r,   r2   setkeysrQ   r  r   r  r   r   r[   r   r.   r4   r6   r8   rT   )r  r  r   rg   	new_hostsn_to_adds   &&    r+   )_updated_topology_description_srv_pollingr"    s-     --1GGGG

2
2
4C 388:#h-'## 
#"GGG $ ))Q.MC
O3	'55C@a<fY/Xs9~1NOHH,W5CL  **--,,,,// r*   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r0   r   +MutableMapping[_Address, ServerDescription]r4   r5   r  r   r6   r7   r8   r9   r;   z<tuple[int, Optional[str], Optional[int], Optional[ObjectId]]r#   )r=   s   "r+   r>   r>   F  sU     UY UY	4UY#UY *UY #	UY
 (UY BUYr*   c                |   Vf   VP                   pM9WP                   8w  d*   V P                  VP                  4       \        V 4      WV3# VP                  e   VP                  ^8  d   VP
                  VP                  3pW43pRV9  dT   RV9  dA   WV8  d;   VP                  \        RV RV 24      4      WP                  &   \        V 4      WV3# VP                  pVP
                  e"   Ve   VP
                  V8  d   VP
                  pMVP                  VP
                  3pWC3p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      pWx8  d;   VP                  \        RV RV 24      4      WP                  &   \        V 4      WV3# VP                  pVP
                  pV P                  4        Ff  p	V	P                  \        P                  J g   K#  V	P                  VP                  8w  g   K@  V	P                  \        R4      4      W	P                  &    M	  VP                   F  p
W9  g   K  \        V
4      W
&   K  	  \!        V 4      VP                  ,
           F  pV P                  V4       K  	  \        V 4      WV3# )aO  Update topology description from a primary's hello response.

Pass in a dict of ServerDescriptions, current replica set name, the
ServerDescription we are processing, and the TopologyDescription's
max_set_version and max_election_id if any.

Returns (new topology type, new replica_set_name, new max_set_version,
new max_election_id).
Nz<primary marked stale due to electionId/setVersion mismatch, z is stale compared to c              3  @   "   T F  qf   \        4       MTx  K  	  R # 5irB   r   rF   is   & r+   rH   *_update_rs_from_primary.<locals>.<genexpr>t       ![HZ1i&(Q">HZ   c              3  @   "   T F  qf   \        4       MTx  K  	  R # 5irB   r   r'  s   & r+   rH   r)  u  r*  r+  z6primary marked stale due to discovery of newer primary)r4   r  rg   r  re   set_versionelection_idrx   r   tuplerR   r   r   r   	all_hostsr   r  )r   r4   r  r6   r8   new_election_tuplemax_election_tuplenew_election_safemax_election_safer   new_addressaddrs   &&&&&       r+   r  r  F  s     ->>	@@	@ 	"**+!#&(8?ZZ**26H6Y6Y\^6^%7%C%CEWEcEc$d%4$F))--2D2Y2D2O2O VWiVj  kA  BT  AU  V3../
 *#.0@Sbbb0<<O))5#'9'E'E'W0<<O/;;=O=[=[[,=!E![HZ![EE![HZ![[!E![HZ![EE![HZ![[0.@.K.KRSeRff|  ~P  }Q  R/C**+
 &c*,<^^0<<O0<<O **,+"7"77"4"<"<< #)"3"3UV#C
   *33!0=C 4
 C-7777 8
 s#%5XXr*   c               (    V ^8  d   QhRRRRRRRR/# )	r0   r   r$  r4   r5   r  r   r;   r   r#   )r=   s   "r+   r>   r>     s0     # #	4### *# 		#r*   c                   Vf   Q hWP                   8w  d   V P                  VP                  4       MHVP                  '       d7   VP                  VP                  8w  d   V P                  VP                  4       \	        V 4      # )zRS with known primary. Process a response from a non-primary.

Pass in a dict of ServerDescriptions, current replica set name, and the
ServerDescription we are processing.

Returns new topology type.
)r4   r  rg   mer  )r   r4   r  s   &&&r+   r  r    sp     '''>>>"**+				#5#=#=ASAVAV#V"**+ c""r*   c               (    V ^8  d   QhRRRRRRRR/# )	r0   r   r$  r4   r5   r  r   r;   ztuple[int, Optional[str]]r#   )r=   s   "r+   r>   r>     s0     + +	4+#+ *+ 	+r*   c                   \         P                  pVf   VP                  pM.WP                  8w  d   V P                  VP                  4       W13# VP
                   F  pW@9  g   K  \        V4      W&   K  	  VP                  '       d7   VP                  VP                  8w  d   V P                  VP                  4       W13# )zRS without known primary. Update from a non-primary's response.

Pass in a dict of ServerDescriptions, current replica set name, and the
ServerDescription we are processing.

Returns (new topology type, new replica_set_name).
)rV   r   r4   r  rg   r0  r   r9  )r   r4   r  r1   rg   s   &&&  r+   r  r    s     "55M->>	@@	@"**+.. &//,W5CL 0 !3!;!;?Q?T?T!T"**+**r*   c                    V ^8  d   QhRRRR/# )r0   r   z$Mapping[_Address, ServerDescription]r;   r   r#   )r=   s   "r+   r>   r>     s     1 1@ 1S 1r*   c                    V P                  4        F4  pVP                  \        P                  8X  g   K$  \        P
                  u # 	  \        P                  # )zCurrent topology type is ReplicaSetWithPrimary. Is primary still known?

Pass in a dict of ServerDescriptions.

Returns new topology type.
)rR   r   r   r   rV   r   r   )r   rG   s   & r+   r  r    s@     ZZ\==K111 666  000r*   N)<__conditional_annotations____doc__
__future__r   randomr   typingr   r   r   r   r   r	   r
   r   bson.min_keyr   bson.objectidr   pymongor   pymongo.errorsr   r   pymongo.read_preferencesr   r   r   r   pymongo.server_descriptionr   pymongo.server_selectorsr   pymongo.server_typer   pymongo.typingsr   r   rangerV   r!   r    r,   r(   _ServerSelectorr.   r  r   r   r  r   r  r  r  ry   r"  r  r  r  r  )r>  s   @r+   <module>rN     s-   # 	 	 	   "  ; X X 8 . + $J  uQx( ,9+@+@-BWBW*X  X D!234d;L6MMNe
 e
V --=>>]>>=<<::! eP(VUYp#.+@1r*   