Skip to content

Commit

Permalink
take str or float timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
beasteers committed Oct 30, 2023
1 parent 16fc185 commit 5aad417
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion redis_record/storage/recorder/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, out_dir='.', max_len=1000, max_size=9.5*MB):
def write(self, stream_id, timestamp, data):
assert set(data) == {b'd'}, f"zip recorder can only record a single field in a stream. got {set(data)}"
self.ensure_channel(stream_id)
self.writer[stream_id].write(data[b'd'], format_epoch_time(timestamp))
self.writer[stream_id].write(data[b'd'], timestamp)

def close(self):
if self.writer:
Expand Down Expand Up @@ -60,6 +60,8 @@ def __exit__(self, e, t, tb):

def write(self, data, ts):
self.size += len(data)
if not isinstance(timestamp, str):
timestamp = format_epoch_time(timestamp)
self.buffer.append([data, ts])
if len(self.buffer) >= self.max_len or self.size >= self.max_size:
self._dump(self.buffer)
Expand Down

0 comments on commit 5aad417

Please sign in to comment.