|
|
@@ -123,7 +123,7 @@ class Client(object): |
|
|
|
This may make multiple requests to the server, if the data is |
|
|
|
large enough or enough time has passed between insertions. |
|
|
|
""" |
|
|
|
ctx = StreamInserter(self.http, path, start, end) |
|
|
|
ctx = StreamInserter(self, path, start, end) |
|
|
|
yield ctx |
|
|
|
ctx.finalize() |
|
|
|
|
|
|
@@ -219,13 +219,13 @@ class StreamInserter(object): |
|
|
|
# Delta to add to the final timestamp, if "end" wasn't given |
|
|
|
_end_epsilon = 1e-6 |
|
|
|
|
|
|
|
def __init__(self, http, path, start = None, end = None): |
|
|
|
def __init__(self, client, path, start = None, end = None): |
|
|
|
"""'http' is the httpclient object. 'path' is the database |
|
|
|
path to insert to. 'start' and 'end' are used for the first |
|
|
|
contiguous interval.""" |
|
|
|
self.last_response = None |
|
|
|
|
|
|
|
self._http = http |
|
|
|
self._client = client |
|
|
|
self._path = path |
|
|
|
|
|
|
|
# Start and end for the overall contiguous interval we're |
|
|
@@ -340,11 +340,9 @@ class StreamInserter(object): |
|
|
|
|
|
|
|
def _send_block(self, block_end): |
|
|
|
"""Send current block to the server""" |
|
|
|
params = { "path": self._path, |
|
|
|
"start": float_to_string(self._block_start), |
|
|
|
"end": float_to_string(block_end) } |
|
|
|
self.last_response = self._http.put("stream/insert", |
|
|
|
"".join(self._block_data), params) |
|
|
|
self.last_response = self._client.stream_insert_block( |
|
|
|
self._path, "".join(self._block_data), |
|
|
|
self._block_start, block_end) |
|
|
|
|
|
|
|
# Clear out the block |
|
|
|
self._block_data = [] |
|
|
|