§
    Štjž5  ã                   ó˜   — d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
  ej        e¦  «        ZdZdZd	Zd
ZdZ G d„ d¦  «        ZdS )zàInformer implementation for the Kubernetes Python client.

Provides SharedInformer: a background watcher that keeps a local
ObjectCache in sync with the Kubernetes API server and notifies
registered event-handler callbacks.
é    N)ÚApiException)ÚWatché   )ÚObjectCacheÚ_meta_namespace_keyÚADDEDÚMODIFIEDÚDELETEDÚBOOKMARKÚERRORc                   ój   — e Zd ZdZ	 	 	 	 	 dd„Zed„ ¦   «         Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ ZdS )ÚSharedInformera;  Watch a Kubernetes resource and maintain a local cache.

    The informer starts a daemon thread that continuously watches the
    given resource via ``list_func``.  On each event the local
    :class:`ObjectCache` is updated and registered
    event-handler callbacks are invoked.

    Parameters
    ----------
    list_func:
        Bound API method used for the initial list **and** as the watch
        source.  It must accept a watch keyword argument (e.g.
        CoreV1Api().list_namespaced_pod).
    namespace:
        Kubernetes namespace to watch.  Pass None for cluster-scoped
        or all-namespace list functions.
    resync_period:
        How often (seconds) to perform a full re-list from the API server.
        Defaults to 0 which disables periodic resyncs.
    label_selector:
        Optional label selector string forwarded to the API server.
    field_selector:
        Optional field selector string forwarded to the API server.
    key_func:
        Optional callable (obj) -> str used to key objects in the
        cache.  Defaults to namespace/name.
    Nr   c           
      óT  — || _         || _        || _        || _        || _        t          |¬¦  «        | _        t          g t          g t          g t          g t          g i| _        t          j        ¦   «         | _        d | _        d | _        t          j        ¦   «         | _        d | _        d S )N)Úkey_func)Ú
_list_funcÚ
_namespaceÚ_resync_periodÚ_label_selectorÚ_field_selectorr   Ú_cacher   r	   r
   r   r   Ú	_handlersÚ	threadingÚLockÚ_handler_lockÚ_watchÚ_threadÚEventÚ_stop_eventÚ_resource_version)ÚselfÚ	list_funcÚ	namespaceÚresync_periodÚlabel_selectorÚfield_selectorr   s          úZ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/kubernetes/informer/informer.pyÚ__init__zSharedInformer.__init__G   s•   € ð $ˆŒØ#ˆŒØ+ˆÔØ-ˆÔØ-ˆÔå!¨8Ð4Ñ4Ô4ˆŒÝ ¥X¨rµ7¸BÅÈ"ÍeÐUWÐXˆŒÝ&œ^Ñ-Ô-ˆÔàˆŒØˆŒÝ$œ?Ñ,Ô,ˆÔØ!%ˆÔÐÐó    c                 ó   — | j         S )z5The :class:`ObjectCache` maintained by this informer.)r   ©r    s    r&   ÚcachezSharedInformer.cachec   s   € ð Œ{Ðr(   c           
      ó(  — || j         vrHt          d                     |d                     t	          | j         ¦  «        ¦  «        ¦  «        ¦  «        ‚| j        5  | j         |                              |¦  «         ddd¦  «         dS # 1 swxY w Y   dS )a_  Register a callback for a specific event type.

        Parameters
        ----------
        event_type:
            One of :data:`ADDED`, :data:`MODIFIED`, :data:`DELETED`,
            :data:`BOOKMARK` or :data:`ERROR`.
        handler:
            Callable invoked with the event object (or the raw exception for
            ERROR events).
        z'Unknown event_type {!r}. Use one of: {}z, N)r   Ú
ValueErrorÚformatÚjoinÚsortedr   Úappend©r    Ú
event_typeÚhandlers      r&   Úadd_event_handlerz SharedInformer.add_event_handlerh   sÛ   € ð ˜Tœ^Ð+Ð+ÝØ9×@Ò@Ø §	¢	­&°´Ñ*@Ô*@Ñ AÔ Añô ñô ð ð
 Ôð 	7ð 	7ØŒN˜:Ô&×-Ò-¨gÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7s   Á!BÂBÂBc                 ó¸   — | j         5  	 | j        |                              |¦  «         n# t          t          f$ r Y nw xY wddd¦  «         dS # 1 swxY w Y   dS )zeDeregister a previously registered *handler*.

        No-op if *handler* is not registered.
        N)r   r   ÚremoveÚKeyErrorr-   r2   s      r&   Úremove_event_handlerz#SharedInformer.remove_event_handler}   s¹   € ð
 Ôð 	ð 	ðØ”˜zÔ*×1Ò1°'Ñ:Ô:Ð:Ð:øÝ�jÐ)ð ð ð Ø�ðøøøð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s,   ˆAŠ +ªA«?¼A¾?¿AÁAÁAc                 óð   — | j         �| j                              ¦   «         rdS | j                             ¦   «          t	          j        | j        dd¬¦  «        | _         | j                              ¦   «          dS )z¢Start the background watch loop in a daemon thread.

        Calling :meth:`start` more than once without an intervening
        :meth:`stop` is a no-op.
        Nr   T)ÚtargetÚnameÚdaemon)r   Úis_aliver   Úclearr   ÚThreadÚ	_run_loopÚstartr*   s    r&   rB   zSharedInformer.startˆ   sy   € ð Œ<Ð#¨¬×(=Ò(=Ñ(?Ô(?Ð#ØˆFØÔ×ÒÑ Ô Ð Ý Ô'Ø”>Ø!Øð
ñ 
ô 
ˆŒð
 	Œ×ÒÑÔÐÐÐr(   c                 óÆ   — | j                              ¦   «          | j        �| j                             ¦   «          | j        �| j                             ¦   «          d| _        dS )z:Ask the background watch loop to stop and join the thread.N)r   Úsetr   Ústopr   r/   r*   s    r&   rE   zSharedInformer.stop˜   sZ   € àÔ×ÒÑÔÐØŒ;Ð"ØŒK×ÒÑÔÐØŒ<Ð#ØŒL×ÒÑÔÐØˆŒˆˆr(   c                 óp   — i }| j         �
| j         |d<   | j        �
| j        |d<   | j        �
| j        |d<   |S )Nr"   r$   r%   )r   r   r   )r    Úkws     r&   Ú_build_kwargszSharedInformer._build_kwargs¥   sM   € ØˆØŒ?Ð&Ø"œoˆBˆ{‰OØÔÐ+Ø#'Ô#7ˆBÐÑ ØÔÐ+Ø#'Ô#7ˆBÐÑ Øˆ	r(   c                 ó  — | j         5  t          | j                             |g ¦  «        ¦  «        }ddd¦  «         n# 1 swxY w Y   |D ]9}	  ||¦  «         Œ# t          $ r t
                               d|¦  «         Y Œ6w xY wdS )a  Execute all registered callbacks for *event_type*, passing *obj*.

        Callbacks are invoked sequentially on the informer's background thread.
        Any exception raised by an individual handler is logged and swallowed so
        that remaining handlers still run.
        Nz$Exception in informer handler for %s)r   Úlistr   ÚgetÚ	ExceptionÚloggerÚ	exception)r    r3   ÚobjÚhandlersÚfns        r&   Ú_firezSharedInformer._fire¯   s  € ð Ôð 	@ð 	@Ý˜DœN×.Ò.¨z¸2Ñ>Ô>Ñ?Ô?ˆHð	@ð 	@ð 	@ñ 	@ô 	@ð 	@ð 	@ð 	@ð 	@ð 	@ð 	@øøøð 	@ð 	@ð 	@ð 	@àð 	ð 	ˆBðØ��3‘”��øÝð ð ð Ý× Ò Ø:¸Jñô ð ð ð ðøøøð	ð 	s!   ˆ)=½AÁAÁAÁ%BÂ Bc                 óÂ  — |                       ¦   «         } | j        di |¤Ž}t          |dg ¦  «        pg }i }|D ]!}| j                             |¦  «        }|||<   Œ"t          | j                             ¦   «         ¦  «        }|D ]=}||vr7| j                             |¦  «        }|�|                      t          |¦  «         Œ>| j         
                    |¦  «         |                     ¦   «         D ]@\  }}||v r|                      t          |¦  «         Œ%|                      t          |¦  «         ŒAd}	t          |dd¦  «        }
|
�t          |
dd¦  «        }	|	pd| _        dS )a¬  List all objects and populate the cache, firing ADDED/MODIFIED/DELETED events.

        On the first call (empty cache) every returned item fires ADDED.
        On subsequent calls (resync or after a 410 Gone) the new list is
        diffed against the existing cache:
        * Items absent from the new list fire DELETED.
        * Items present in both fire MODIFIED.
        * Items only in the new list fire ADDED.
        ÚitemsNÚmetadataÚresource_versionÚ0© )rH   r   Úgetattrr   Ú	_key_funcrD   Ú	list_keysÚ
get_by_keyrR   r
   Ú_replace_allrT   r	   r   r   )r    rG   ÚresprT   Únew_items_mapÚitemÚkeyÚold_keysÚold_objÚrvÚmetas              r&   Ú_initial_listzSharedInformer._initial_listÀ   s“  € ð ×ÒÑ!Ô!ˆØˆtŒÐ$Ð$ Ð$Ð$ˆÝ˜˜g rÑ*Ô*Ð0¨bˆð ˆØð 	&ð 	&ˆDØ”+×'Ò'¨Ñ-Ô-ˆCØ!%ˆM˜#ÑÐõ �t”{×,Ò,Ñ.Ô.Ñ/Ô/ˆð ð 	1ð 	1ˆCØ˜-Ð'Ð'Øœ+×0Ò0°Ñ5Ô5�ØÐ&Ø—J’J�w¨Ñ0Ô0Ð0øð 	Œ× Ò  Ñ'Ô'Ð'ð '×,Ò,Ñ.Ô.ð 	(ð 	(‰IˆC�Ø�hˆˆØ—
’
�8 TÑ*Ô*Ð*Ð*à—
’
�5 $Ñ'Ô'Ð'Ð'àˆÝ�t˜Z¨Ñ.Ô.ˆØÐÝ˜Ð1°4Ñ8Ô8ˆBØ!#  sˆÔÐÐr(   c                 ó¬	  — | j                              ¦   «         �s¹| j        €}	 |                      ¦   «          ng# t          $ rZ}t
                               d¦  «         |                      t          |¦  «         | j          	                    d¬¦  «         Y d}~Œ–d}~ww xY wt          j        ¦   «         }t          ¦   «         | _        |                      ¦   «         }| j        |d<   | j        dk    r%t!          dt#          | j        ¦  «        ¦  «        |d<   	  | j        j        | j        fi |¤ŽD �]“}| j                              ¦   «         r �nv|                     d	¦  «        }|                     d
¦  «        }| j        �| j        j        r| j        j        | _        |t,          k    r6| j                             |¦  «         |                      t,          |¦  «         Œ®|t2          k    r6| j                             |¦  «         |                      t2          |¦  «         Œï|t4          k    r7| j                             |¦  «         |                      t4          |¦  «         �Œ1|t8          k    r1|                      t8          |                     d|¦  «        ¦  «         �Œm|t          k    r|                      t          |¦  «         �Œ•nÆ# t:          $ rr}|j        dk    r"t
                               d¦  «         d| _        n t
                               d|j        ¦  «         |                      t          |¦  «         Y d}~nOd}~wt          $ r?}t
                               d¦  «         |                      t          |¦  «         Y d}~nd}~ww xY w| j        �$| j        �| j        j        r| j        j        | _        d| _        n7# | j        �$| j        �| j        j        r| j        j        | _        d| _        w xY w| j                              ¦   «         s­| j        �¦| j        dk    r›t          j        ¦   «         |z
  | j        k    r|t
                                d¦  «         	 |                      ¦   «          nL# t          $ r?}t
                               d¦  «         |                      t          |¦  «         Y d}~nd}~ww xY w| j                              ¦   «         �¯·dS dS )a†  Background loop: list then watch, reconnect on errors.

        A full re-list is only performed when ``self._resource_version`` is
        ``None`` (first start or after a 410 Gone response).  On all other
        reconnects the most recent ``resourceVersion`` is reused so that no
        events are missed and the API server does not need to send a full
        object snapshot.
        Nz#Error during initial list; retryingé   )ÚtimeoutrV   r   r   Útimeout_secondsÚtypeÚobjectÚ
raw_objectiš  z3Watch expired (410 Gone); will re-list from scratchz>Watch stream ended with ApiException (status=%s); reconnectingz,Unexpected error in watch loop; reconnectingzInformer resync triggeredz$Error during resync list; continuing)!r   Úis_setr   rf   rL   rM   rN   rR   r   ÚwaitÚtimeÚ	monotonicr   r   rH   r   ÚmaxÚintÚstreamr   rK   rV   r   r   Ú_putr	   r
   Ú_remover   r   ÚstatusÚwarningÚdebug)r    ÚexcÚlast_resyncrG   ÚeventÚevt_typerO   s          r&   rA   zSharedInformer._run_loopî   sü  € ð Ô"×)Ò)Ñ+Ô+ñ _	+àÔ%Ð-ðØ×&Ò&Ñ(Ô(Ð(Ð(øÝ ð ð ð Ý×$Ò$Ð%JÑKÔKÐKØ—J’J�u cÑ*Ô*Ð*ØÔ$×)Ò)°!Ð)Ñ4Ô4Ð4Ø�H�H�H�Høøøøð	øøøõ œ.Ñ*Ô*ˆKÝ™'œ'ˆDŒKØ×#Ò#Ñ%Ô%ˆBØ%)Ô%;ˆBÐ!Ñ"ð Ô" QÒ&Ð&Ý(+¨A­s°4Ô3FÑ/GÔ/GÑ(HÔ(H�Ð$Ñ%ð7#Ø/˜Tœ[Ô/°´ÐFÐFÀ2ÐFÐFð /ñ /�EØÔ'×.Ò.Ñ0Ô0ð Ø™Ø$Ÿyšy¨Ñ0Ô0�HØŸ)š) HÑ-Ô-�Cð
 ”{Ð.°4´;Ô3OÐ.Ø15´Ô1M˜Ô.Ø¥5Ò(Ð(Øœ×(Ò(¨Ñ-Ô-Ð-ØŸ
š
¥5¨#Ñ.Ô.Ð.Ð.Ø!¥XÒ-Ð-Øœ×(Ò(¨Ñ-Ô-Ð-ØŸ
š
¥8¨SÑ1Ô1Ð1Ð1Ø!¥WÒ,Ð,Øœ×+Ò+¨CÑ0Ô0Ð0ØŸ
š
¥7¨CÑ0Ô0Ð0Ñ0Ø!¥XÒ-Ð-ð Ÿ
š
¥8¨U¯YªY°|ÀSÑ-IÔ-IÑJÔJÐJÑJØ!¥UÒ*Ð*ØŸ
š
¥5¨#Ñ.Ô.Ð.ùøøÝð 'ð 'ð 'Ø”: Ò$Ð$å—N’NØMñô ð ð .2�DÔ*Ð*å—N’NØXØœ
ñô ð ð —
’
�5 #Ñ&Ô&Ð&Ð&Ð&Ð&Ð&Ð&øøøøÝð 'ð 'ð 'Ý× Ò Ð!OÑPÔPÐPØ—
’
�5 #Ñ&Ô&Ð&Ð&Ð&Ð&Ð&Ð&øøøøð'øøøð Ô*Ð6ØœÐ/ØœÔ4ð 0ð .2¬[Ô-I�DÔ*Ø"�”�øð Ô*Ð6ØœÐ/ØœÔ4ð 0ð .2¬[Ô-I�DÔ*Ø"�”Ð"Ð"Ð"Ð"ð Ô$×+Ò+Ñ-Ô-ð+àÔ*Ð6ØÔ'¨!Ò+Ð+Ý”^Ñ%Ô%¨Ñ3¸Ô8KÒKÐKå—’Ð8Ñ9Ô9Ð9ð+Ø×&Ò&Ñ(Ô(Ð(Ð(øÝ ð +ð +ð +Ý×$Ò$Ð%KÑLÔLÐLØ—J’J�u cÑ*Ô*Ð*Ð*Ð*Ð*Ð*Ð*øøøøð+øøøð{ Ô"×)Ò)Ñ+Ô+ñ _	+ð _	+ð _	+ð _	+ð _	+sr   £8 ¸
BÁABÂBÄF-K ËN; Ë
NËA(L9Ì4N; Ì9NÍ5N Í;N; Î NÎN; Î;4O/ÑQ, Ñ,
R5Ñ65R0Ò0R5)Nr   NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r'   Úpropertyr+   r5   r9   rB   rE   rH   rR   rf   rA   rX   r(   r&   r   r   *   sÜ   € € € € € ðð ð> ØØØØð&ð &ð &ð &ð8 ðð ñ „Xðð7ð 7ð 7ð*	ð 	ð 	ðð ð ð ð ð ðð ð ðð ð ð",+ð ,+ð ,+ð\h+ð h+ð h+ð h+ð h+r(   r   )r�   Úloggingr   rp   Úkubernetes.client.exceptionsr   Úkubernetes.watchr   r+   r   r   Ú	getLoggerr~   rM   r   r	   r
   r   r   r   rX   r(   r&   ú<module>r‡      sÔ   ððð ð €€€Ø Ð Ð Ð Ø €€€à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø "Ð "Ð "Ð "Ð "Ð "à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à	ˆÔ	˜8Ñ	$Ô	$€ð 	€Ø€Ø
€Ø€Ø€ðl+ð l+ð l+ð l+ð l+ñ l+ô l+ð l+ð l+ð l+r(   