Ë
    èlÖië  ã                   ód   — d dl mZ d dlmZ d dlmZmZ d dlmZ  G d„ de«      Z	 G d„ de	«      Z
y	)
é    )ÚList)ÚProtocol)ÚPayloadDictÚPayloadDictList)ÚLoggerc                   óL   — e Zd ZdZdedefd„Zdefd„Zdededdfd	„Z	de
fd
„Zy)Ú
EventStorezC
    EventStore protocol. For buffering events in the Emitter.
    ÚpayloadÚreturnc                  ó   — y)z­
        Add PayloadDict to buffer. Returns True if successful.

        :param payload: The payload to add
        :type  payload: PayloadDict
        :rtype  bool
        N© ©Úselfr
   s     úa/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/snowplow_tracker/event_store.pyÚ	add_eventzEventStore.add_event   s   € ð 	ó    c                  ó   — y)zd
        Get a list of all the PayloadDicts in the buffer.

        :rtype  PayloadDictList
        Nr   ©r   s    r   Úget_events_batchzEventStore.get_events_batch'   ó   € ð 	r   ÚbatchÚ
need_retryNc                  ó   — y)aL  
        Removes sent events from the event store. If events need to be retried they are re-added to the buffer.

        :param  batch:  The events to be removed from the buffer
        :type   batch:  PayloadDictList
        :param  need_retry  Whether the events should be re-sent or not
        :type   need_retry  bool
        Nr   )r   r   r   s      r   ÚcleanupzEventStore.cleanup/   s   € ð 	r   c                  ó   — y)úQ
        Returns the number of events in the buffer

        :rtype  int
        Nr   r   s    r   ÚsizezEventStore.size:   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úboolr   r   r   r   Úintr   r   r   r   r	   r	      sL   „ ñð ð °ó ð /ó ð	˜_ð 	¸$ð 	À4ó 	ð�cô r   r	   c                   ón   — e Zd ZdZddededdfd„Zdedefd„Z	de
fd	„Zd
e
deddfd„Zdefd„Zdefd„Zy)ÚInMemoryEventStorezg
    Create a InMemoryEventStore object with custom buffer capacity. The default is 10,000 events.
    ÚloggerÚbuffer_capacityr   Nc                 ó.   — g | _         || _        || _        y)a  
        :param  logger: Logging module
        :type   logger: Logger
        :param  buffer_capacity:    The maximum capacity of the event buffer.
                                    When the buffer is full new events are lost.
        :type   buffer_capacity     int
        N)Úevent_bufferr'   r&   )r   r&   r'   s      r   Ú__init__zInMemoryEventStore.__init__H   s   € ð 02ˆÔØ.ˆÔØˆ�r   r
   c                 ó’   — | j                  «       r| j                  j                  d«       y| j                  j	                  |«       y)z|
        Add PayloadDict to buffer.

        :param payload: The payload to add
        :type  payload: PayloadDict
        z%Event buffer is full, dropping event.FT)Ú_buffer_capacity_reachedr&   Úerrorr)   Úappendr   s     r   r   zInMemoryEventStore.add_eventT   s=   € ð ×(Ñ(Ô*Ø�K‰K×ÑÐEÔFØà×Ñ× Ñ  Ô)Ør   c                 ó,   — | j                   }g | _         |S )zk
        Get a list of all the PayloadDicts in the in the buffer.

        :rtype  PayloadDictList
        )r)   )r   r   s     r   r   z#InMemoryEventStore.get_events_batchb   s   € ð ×!Ñ!ˆØˆÔØˆr   r   r   c                 ó\   — |sy|D ]$  }|| j                   vsŒ| j                  |«      rŒ$ y y)aZ  
        Removes sent events from the InMemoryEventStore buffer. If events need to be retried they are re-added to the buffer.

        :param  batch:  The events to be removed from the buffer
        :type   batch:  PayloadDictList
        :param  need_retry  Whether the events should be re-sent or not
        :type   need_retry  bool
        N)r)   r   )r   r   r   Úevents       r   r   zInMemoryEventStore.cleanupl   s6   € ñ Øàò 	ˆEØ˜D×-Ñ-Ò-Ø—~‘~ eÕ,Ùñ	r   c                 ó,   — t        | j                  «      S )r   )Úlenr)   r   s    r   r   zInMemoryEventStore.size}   s   € ô �4×$Ñ$Ó%Ð%r   c                 ó<   — | j                  «       | j                  k\  S )zR
        Returns true if buffer capacity is reached

        :rtype: bool
        )r   r'   r   s    r   r,   z+InMemoryEventStore._buffer_capacity_reached…   s   € ð �y‰y‹{˜d×2Ñ2Ñ2Ð2r   )i'  )r   r   r    r!   r   r#   r*   r   r"   r   r   r   r   r   r,   r   r   r   r%   r%   C   sr   „ ññ
˜vð 
¸ð 
Èó 
ð ð °ó ð /ó ð˜_ð ¸$ð À4ó ð"&�có &ð3¨$ô 3r   r%   N)Útypingr   Útyping_extensionsr   Úsnowplow_tracker.typingr   r   Úloggingr   r	   r%   r   r   r   ú<module>r9      s.   ðõ$ Ý &ß @Ý ô(�ô (ôVH3˜õ H3r   