Skip to content

Commit c288c38

Browse files
committed
feat: update swagger with a delete endpoint
1 parent 07dfa9c commit c288c38

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

influxdb_client/client/write_api.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ def _window_to_group(value):
119119
return value.pipe(
120120
ops.to_iterable(),
121121
ops.map(lambda x: rx.from_iterable(x).pipe(
122-
ops.group_by(_group_by), ops.map(_group_to_batch), ops.merge_all())), ops.merge_all())
122+
# Group window by 'organization', 'bucket' and 'precision'
123+
ops.group_by(_group_by),
124+
# Create batch (concatenation line protocols by \n)
125+
ops.map(_group_to_batch),
126+
ops.merge_all())), ops.merge_all())
123127

124128

125129
class WriteApi(AbstractClient):
@@ -129,15 +133,20 @@ def __init__(self, influxdb_client, write_options: WriteOptions = WriteOptions()
129133
self._write_service = WriteService(influxdb_client.api_client)
130134
self._write_options = write_options
131135
if self._write_options.write_type is WriteType.batching:
136+
# Define Subject that listen incoming data and produces writes into InfluxDB
132137
self._subject = Subject()
133138

139+
# Define a scheduler that is used for processing incoming data - default singleton
134140
observable = self._subject.pipe(ops.observe_on(self._write_options.write_scheduler))
135141
self._disposable = observable \
136-
.pipe(ops.window_with_time_or_count(count=write_options.batch_size,
137-
timespan=timedelta(milliseconds=write_options.flush_interval)),
138-
ops.flat_map(lambda v: _window_to_group(v)),
139-
ops.map(mapper=lambda x: self._retryable(data=x, delay=self._jitter_delay())),
140-
ops.merge_all()) \
142+
.pipe( # Split incoming data to windows by batch_size or flush_interval
143+
ops.window_with_time_or_count(count=write_options.batch_size,
144+
timespan=timedelta(milliseconds=write_options.flush_interval)),
145+
# Map incoming batch window in groups defined by 'organization', 'bucket' and 'precision'
146+
ops.flat_map(lambda v: _window_to_group(v)),
147+
# Write data into InfluxDB (possibility to retry if its fail)
148+
ops.map(mapper=lambda batch: self._retryable(data=batch, delay=self._jitter_delay())), #
149+
ops.merge_all()) \
141150
.subscribe(self._on_next, self._on_error, self._on_complete)
142151
else:
143152
self._subject = None
@@ -244,8 +253,11 @@ def _post_write(self, _async_req, bucket, org, body, precision):
244253
def _retryable(self, data: str, delay: timedelta):
245254

246255
return rx.of(data).pipe(
256+
# use delay if its specified
247257
ops.delay(duetime=delay, scheduler=self._write_options.write_scheduler),
258+
# invoke http call
248259
ops.map(lambda x: self._http(x)),
260+
# if there is an error than retry
249261
ops.catch(handler=lambda exception, source: self._retry_handler(exception, source, data)),
250262
)
251263

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy