+
    4O|jÀ  ã                  óŽ   € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]'       d   ^ RI	H
t
 ^
t^ZtR R ltR R	 ltR
 R ltR R ltR# )aò  Criteria to select ServerDescriptions based on maxStalenessSeconds.

The Max Staleness Spec says: When there is a known primary P,
a secondary S's staleness is estimated with this formula:

  (S.lastUpdateTime - S.lastWriteDate) - (P.lastUpdateTime - P.lastWriteDate)
  + heartbeatFrequencyMS

When there is no known primary, a secondary S's staleness is estimated with:

  SMax.lastWriteDate - S.lastWriteDate + heartbeatFrequencyMS

where "SMax" is the secondary with the greatest lastWriteDate.
)Úannotations)ÚTYPE_CHECKING)ÚConfigurationError)ÚSERVER_TYPE)Ú	Selectionc               ó$   € V ^8„  d   QhRRRRRR/# )é   Úmax_stalenessÚintÚheartbeat_frequencyÚreturnÚNone© )Úformats   "ÚXC:\Users\alokc\chatbot\backend\venv\Lib\site-packages\pymongo/max_staleness_selectors.pyÚ__annotate__r   .   s!   € ÷ 
ñ 
¨3ð 
ÀSð 
ÈTñ 
ó    c                ó¬   € W\         ,           8  d    \        R \         WR,          3,          4      hV \        8  d   \        R\        V 3,          4      hR# )zŒmaxStalenessSeconds must be at least heartbeatFrequencyMS + %d seconds. maxStalenessSeconds is set to %d, heartbeatFrequencyMS is set to %d.iè  zJmaxStalenessSeconds must be at least %d. maxStalenessSeconds is set to %d.N)ÚIDLE_WRITE_PERIODr   ÚSMALLEST_MAX_STALENESS)r	   r   s   &&r   Ú_validate_max_stalenessr   .   se   € àÔ->Õ>Ô>Ü ð2ô ! -ÀtÕ1KÐLõMó
ð 	
ð Ô-Ô-Ü ð0Ü3IÈ=Ð2YõZó
ð 	
ñ .r   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r	   r
   Ú	selectionr   r   r   )r   s   "r   r   r   ?   s!   € ÷ 3ñ 3 ð 3°ð 3¸yñ 3r   c                óü  € VP                   pV'       g   Q h. pVP                   FÄ  pVP                  \        P                  8X  d’   VP
                  '       d   VP
                  '       g   Q hVP                  VP
                  ,
          VP                  VP
                  ,
          ,
          VP                  ,           pWP8:  d   VP                  V4       K±  K³  VP                  V4       KÆ  	  VP                  V4      # )zEApply max_staleness, in seconds, to a Selection with a known primary.)
ÚprimaryÚserver_descriptionsÚserver_typer   ÚRSSecondaryÚlast_write_dateÚlast_update_timer   ÚappendÚwith_server_descriptions)r	   r   r   ÚsdsÚsÚ	stalenesss   &&    r   Ú_with_primaryr&   ?   sÑ   € à×Ñ€Gß€Nˆ7Ø
€Cà×*Ô*ˆØ�=‰=œK×3Ñ3Ô3à×$×$Ð$¨×)@×)@Ð)@Ð@Ð@à×#Ñ# a×&7Ñ&7Õ7Ø×+Ñ+¨g×.EÑ.EÕEõGà×/Ñ/õ0ð ð Ô)Ø—
‘
˜1–ñ *ð �J‰J�qŽMñ +ð ×-Ñ-¨cÓ2Ð2r   c               ó$   € V ^8„  d   QhRRRRRR/# r   r   )r   s   "r   r   r   W   s!   € ÷ 3ñ 3˜sð 3¨yð 3¸Yñ 3r   c                óÞ  € VP                  4       pV'       g   VP                  . 4      # . pVP                   F¢  pVP                  \        P
                  8X  dp   VP                  '       d   VP                  '       g   Q hVP                  VP                  ,
          VP                  ,           pWP8:  d   VP                  V4       K�  K‘  VP                  V4       K¤  	  VP                  V4      # )zFApply max_staleness, in seconds, to a Selection with no known primary.)	Ú"secondary_with_max_last_write_dater"   r   r   r   r   r   r   r!   )r	   r   Úsmaxr#   r$   r%   s   &&    r   Ú_no_primaryr+   W   sÁ   € ð ×7Ñ7Ó9€Dßà×1Ñ1°"Ó5Ð5à
€Cà×*Ô*ˆØ�=‰=œK×3Ñ3Ô3à×'×'Ð'¨A×,=×,=Ð,=Ð=Ð=Ø×,Ñ,¨q×/@Ñ/@Õ@À9×C`ÑC`Õ`ˆIàÔ)Ø—
‘
˜1–ñ *ð �J‰J�qŽMñ +ð ×-Ñ-¨cÓ2Ð2r   c               ó$   € V ^8„  d   QhRRRRRR/# r   r   )r   s   "r   r   r   o   s!   € ÷ 5ñ 5˜#ð 5¨)ð 5¸	ñ 5r   c                óŽ   € V R8X  d   V# \        WP                  4       VP                  '       d   \        W4      # \	        W4      # )z0Apply max_staleness, in seconds, to a Selection.éÿÿÿÿ)r   r   r   r&   r+   )r	   r   s   &&r   Úselectr/   o   sB   € à˜ÔØÐô
 ˜M×+HÑ+HÔIà××ÐÜ˜]Ó6Ð6ä˜=Ó4Ð4r   N)Ú__doc__Ú
__future__r   Útypingr   Úpymongo.errorsr   Úpymongo.server_typer   Úpymongo.server_selectorsr   r   r   r   r&   r+   r/   r   r   r   Ú<module>r6      s@   ðñõ #å  å -Ý +çÝ2ð
 Ð ØÐ õ
õ"3õ03÷05r   