o
    Á¿iâ  ã                   @   s.   d dl mZ d dlmZ d	dd„Zdd„ ZdS )
é    )Údata_streams_processor)ÚPROPAGATION_KEY_BASE_64Tc                 C   sF   t ƒ }|r!| |tƒ¡ d|  d| dg}|r| d¡ | |¡S dS )aƒ  
    :param typ: The type of the checkpoint, usually the streaming technology being used.
        Examples include kafka, kinesis, sns etc. (str)
    :param source: The source of data. This can be a topic, exchange or stream name. (str)
    :param carrier_get: A function used to extract context from the carrier (function (str) -> str)
    :param manual_checkpoint: Whether this checkpoint was manually set. Keep true if manually instrumenting.
        Manual instrumentation always overrides automatic instrumentation in the case a call is both
        manually and automatically instrumented. (bool)

    :returns DataStreamsCtx | None
    útype:útopic:zdirection:inúmanual_checkpoint:trueN)r   Údecode_pathway_b64r   ÚappendÚset_checkpoint)ÚtypÚsourceÚcarrier_getÚmanual_checkpointÚ	processorÚtags© r   úH/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/data_streams.pyÚset_consume_checkpoint   s   

ûr   c                 C   sB   t ƒ }|r| d|  d| ddg¡}|dur|t| ¡ ƒ |S dS )a§  
    :param typ: The type of the checkpoint, usually the streaming technology being used. Examples include
        kafka, kinesis, sns etc. (str)
    :param target: The destination to which the data is being sent. For instance: topic, exchange or
        stream name. (str)
    :param carrier_set: A function used to inject the context into the carrier (function (str, str) -> None)

    :returns DataStreamsCtx | None
    r   r   zdirection:outr   N)r   r	   r   Ú
encode_b64)r
   ÚtargetÚcarrier_setr   Úpathwayr   r   r   Úset_produce_checkpoint   s   
ÿúr   N)T)Úddtrace.internal.datastreamsr   Ú&ddtrace.internal.datastreams.processorr   r   r   r   r   r   r   Ú<module>   s    
