
    i*                     x    S SK r  S SKrSSKJr  \ R
                  " S5      r " S S\5      rg! \ a    Sr N.f = f)    N   )PubSubManagersocketioc                   J   ^  \ rS rSrSrSr  S	U 4S jjrS rS rS r	Sr
U =r$ )
KafkaManager   a  Kafka based client manager.

This class implements a Kafka backend for event sharing across multiple
processes.

To use a Kafka backend, initialize the :class:`Server` instance as
follows::

    url = 'kafka://hostname:port'
    server = socketio.Server(client_manager=socketio.KafkaManager(url))

:param url: The connection URL for the Kafka server. For a default Kafka
            store running on the same host, use ``kafka://``. For a highly
            available deployment of Kafka, pass a list with all the
            connection URLs available in your cluster.
:param channel: The channel name (topic) on which the server sends and
                receives notifications. Must be the same in all the
                servers.
:param write_only: If set to ``True``, only initialize to emit events. The
                   default of ``False`` initializes the class for emitting
                   and receiving. A write-only instance can be used
                   independently of the server to emit to clients from an
                   external process.
:param logger: a custom logger to log it. If not given, the server logger
               is used.
:param json: An alternative JSON module to use for encoding and decoding
             packets. Custom json modules must have ``dumps`` and ``loads``
             functions that are compatible with the standard library
             versions. This setting is only used when ``write_only`` is set
             to ``True``. Otherwise the JSON module configured in the
             server is used.
kafkac                 n  > [         c  [        S5      e[        TU ]  X#UUS9  [	        U[
        5      (       a  U/OUnU Vs/ s H  nUS:w  a  USS  OSPM     snU l        [         R                  " U R                  S9U l        [         R                  " U R                  U R                  S9U l        g s  snf )NzZkafka-python package is not installed (Run "pip install kafka-python" in your virtualenv).)channel
write_onlyloggerjsonzkafka://   zlocalhost:9092)bootstrap_servers)r	   RuntimeErrorsuper__init__
isinstancestr
kafka_urlsKafkaProducerproducerKafkaConsumerr   consumer)selfurlr   r   r   r   urls	__class__s          S/home/admin/cozy_coffee/venv/lib/python3.13/site-packages/socketio/kafka_manager.pyr   KafkaManager.__init__0   s    =  . / / 	" 	 	$ #3,,u#&*,&*s '*Z&73qr7=MM&*,++dooN++DLL>BooO,s   B2c                     U R                   R                  U R                  U R                  R	                  U5      S9  U R                   R                  5         g )N)value)r   sendr   r   dumpsflush)r   datas     r   _publishKafkaManager._publishA   s:    4<<tyyt/DE    c              #   8   #    U R                    S h  vN   g  N7fN)r   )r   s    r   _kafka_listenKafkaManager._kafka_listenE   s     ==  s   c              #      #    U R                  5        H-  nUR                  U R                  :X  d  M  UR                  v   M/     g 7fr+   )r,   topicr   r"   )r   messages     r   _listenKafkaManager._listenH   s2     ))+G}},mm# ,s
   ,AA)r   r   r   )zkafka://localhost:9092r   FNN)__name__
__module____qualname____firstlineno____doc__namer   r'   r,   r1   __static_attributes____classcell__)r   s   @r   r   r      s0    @ D=G59O"!$ $r)   r   )loggingr	   ImportErrorpubsub_managerr   	getLoggerr   r    r)   r   <module>r@      sG     *			:	&>$= >$  Es   . 99