U viOb @ s d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z ddl m Z ddlmZ ddl mZmZmZmZ ddlZdd lmZmZ dd lmZ ddlmZ ddlmZ dd lmZmZ ddl m!Z! ddl"m#Z# ddl$m%Z%m&Z& ddl'm(Z( ddl)m*Z* e+dZ,er ddl-Z-ddl-m.Z. G dd de Z/G dd de0Z1e1e/j2dZ3e1e/j4dZ5G dd de0Z6G dd de0Z7G dd de0Z8G d d! d!e0Z9d"d# Z:G d$d% d%eZ;dS )&zECollect and write time series data to InfluxDB Cloud or InfluxDB OSS. N)defaultdict) timedelta)Enum)random)sleep)UnionAnyIterable NamedTuple) operators Observable)ThreadPoolScheduler)Subject)WritePrecision) _BaseWriteApi_HAS_DATACLASS)get_org_query_param)DataframeSerializer)PointDEFAULT_WRITE_PRECISION)WritesRetry)_UTF_8_encodingz influxdb_client.client.write_api) dataclassc @ s e Zd ZdZdZdZdZdS ) WriteTypez3Configuration which type of writes will client use. N)__name__ __module____qualname____doc__batchingasynchronoussynchronous r$ r$ Q/opt/alt/python38/lib/python3.8/site-packages/influxdb_client/client/write_api.pyr # s r c @ sX e Zd ZdZejddddddddd ed dfedd ddZdd Zdd Z dd Z dS )WriteOptionszWrite configuration. r i iH i r i r max_workersN) write_typereturnc C sF || _ || _|| _|| _|| _|| _|| _|| _| | _|| _ | | _ dS )aw Create write api configuration. :param write_type: methods of write (batching, asynchronous, synchronous) :param batch_size: the number of data point to collect in batch :param flush_interval: flush data at least in this interval (milliseconds) :param jitter_interval: this is primarily to avoid large write spikes for users running a large number of client instances ie, a jitter of 5s and flush duration 10s means flushes will happen every 10-15s (milliseconds) :param retry_interval: the time to wait before retry unsuccessful write (milliseconds) :param max_retries: the number of max retries when write fails, 0 means retry is disabled :param max_retry_delay: the maximum delay between each retry attempt in milliseconds :param max_retry_time: total timeout for all retry attempts in milliseconds, if 0 retry is disabled :param exponential_base: base for the exponential retry delay :parama max_close_wait: the maximum time to wait for writes to be flushed if close() is called :param write_scheduler: N)r+ batch_sizeflush_intervaljitter_intervalretry_intervalmax_retriesmax_retry_delaymax_retry_timeexponential_basewrite_schedulermax_close_wait)selfr+ r- r. r/ r0 r1 r2 r3 r4 r6 r5 r$ r$ r% __init__. s zWriteOptions.__init__c K s> t | j| jd | jd | jd | jd | j|dddgdS )a" Create a Retry strategy from write options. :key retry_callback: The callable ``callback`` to run after retryable error occurred. The callable must accept one argument: - `Exception`: an retryable error r' retry_callbackNPOST)totalr0 r/ r2 r3 r4 r9 allowed_methods)r r1 r0 r/ r2 r3 r4 get)r7 kwargsr$ r$ r% to_retry_strategyU s zWriteOptions.to_retry_strategyc C s | j }|d= |S )4Return a dict of attributes that you want to pickle.r5 __dict__copyr7 stater$ r$ r% __getstate__g s zWriteOptions.__getstate__c C s | j | tdd| _dS )'Set your object with the provided dict.r r) N)rB updater r5 rD r$ r$ r% __setstate__n s zWriteOptions.__setstate__)r r r r r r! r r8 r? rF rI r$ r$ r$ r% r&