+
    8iD                        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   "]/var/www/html/photoedit/myenv/lib/python3.14/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# )zmaxStalenessSeconds 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 !-t1KLM
 	
 -- 03I=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 3y 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N7
C**==K333$$$)@)@)@@@##a&7&77++g.E.EEG//0  )

1 * JJqM + --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 3s 3y 3Y 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9D11"55
C**==K333'''A,=,=,===,,q/@/@@9C`C``I)

1 * JJqM + --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
   
"30305r   