U
    hz                     @   s   d dl Z d dlmZ ddlmZmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZ G d	d
 d
eZG dd dee jjZG dd dee jj Z dS )    N)bool_ok   )get_protocol_versionparse_to_list   )	ALTER_CMD
CREATE_CMDCREATERULE_CMDDEL_CMDDELETERULE_CMDGET_CMDINFO_CMDMGET_CMD
MRANGE_CMDMREVRANGE_CMDQUERYINDEX_CMD	RANGE_CMDREVRANGE_CMDTimeSeriesCommands)TSInfo)	parse_getparse_m_getparse_m_rangeparse_rangec                   @   s$   e Zd ZdZdddZd	ddZdS )

TimeSeriesz
    This class subclasses redis-py's `Redis` and implements RedisTimeSeries's
    commands (prefixed with "ts").
    The client allows to interact with RedisTimeSeries and use all of it's
    functionality.
    Nc                 K   s   t ttttttti| _tttt	t
ttttttttttttti	}i }|| _|j| _t| jdkrl| j| n| j| | j D ]\}}| j|| qdS )z$Create a new RedisTimeSeries client.)3   N)r   r   r   r	   r   _MODULE_CALLBACKSr
   intr   r   r   r   r   r   r   r   r   r   r   r   r   r   clientZexecute_commandr   updateitemsZset_response_callback)selfr   kwargsZ_RESP2_MODULE_CALLBACKSZ_RESP3_MODULE_CALLBACKSkv r&   F/tmp/pip-unpacked-wheel-4avdqdik/redis/commands/timeseries/__init__.py__init__!   sH                 zTimeSeries.__init__Tc                 C   sn   t | jtjrTt| jj| jj| jjj| jj| jj	| jj
 | jj| jj| jjd	}nt| jj| j||d}|S )aL  Creates a pipeline for the TimeSeries module, that can be used
        for executing only TimeSeries commands and core commands.

        Usage example:

        r = redis.Redis()
        pipe = r.ts().pipeline()
        for i in range(100):
            pipeline.add("with_pipeline", i, 1.1 * i)
        pipeline.execute()

        )	nodes_managercommands_parserstartup_nodesresult_callbackscluster_response_callbacksZcluster_error_retry_attemptsread_from_replicasreinitialize_stepslock)connection_poolZresponse_callbackstransaction
shard_hint)
isinstancer   redisZRedisClusterClusterPipeliner)   r*   r+   r,   r-   retryZget_retriesr.   r/   _lockPipeliner1   r   )r"   r2   r3   pr&   r&   r'   pipelineC   s&    
zTimeSeries.pipeline)N)TN)__name__
__module____qualname____doc__r(   r;   r&   r&   r&   r'   r      s   
"r   c                   @   s   e Zd ZdZdS )r6   z Cluster pipeline for the module.Nr<   r=   r>   r?   r&   r&   r&   r'   r6   g   s   r6   c                   @   s   e Zd ZdZdS )r9   zPipeline for the module.Nr@   r&   r&   r&   r'   r9   k   s   r9   )!r5   Zredis._parsers.helpersr   Zhelpersr   r   commandsr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   infor   utilsr   r   r   r   r   Zclusterr6   r   r9   r&   r&   r&   r'   <module>   s   @N