WriteStream#
- class nominal.core.WriteStream(batch_size, max_wait)#
Bases:
WriteStreamBase[StreamType]A buffered asynchronous writer for time-series or log data.
- close(wait=True)#
Close the Nominal Stream.
Stop the process timeout thread and flush any remaining batches.
- classmethod create(batch_size, max_wait, process_batch)#
Create the stream.
- enqueue(channel_name, timestamp, value, tags=None)#
Add a message to the queue after normalizing the timestamp to IntegralNanosecondsUTC.
The message is added to the thread-safe batch and flushed if the batch size is reached.
- enqueue_batch(channel_name, timestamps, values, tags=None)#
Add a sequence of messages to the queue to upload to Nominal.
Messages are added one-by-one (with timestamp normalization) and flushed based on the batch conditions.
- Parameters:
channel_name (str)
Name of the channel to upload data for.
timestamps (Sequence[str | datetime | int])
Absolute timestamps of the data being uploaded.
values (Sequence[StreamType])
Values to write to the specified channel.
tags (Mapping[str, str] | None)
Key-value tags associated with the data being uploaded.
Note: This must include all
required_tagsconfigured for the dataset.
- enqueue_float_array(channel_name, timestamp, value, tags=None)#
Add an array of floats to the queue after normalizing the timestamp.
- enqueue_from_dict(timestamp, channel_values, tags=None)#
Write multiple channel values at a given timestamp using a flattened dictionary.
Each key in the dictionary is treated as a channel name and the corresponding value is enqueued with the given timestamp.
- Parameters:
timestamp (str | datetime | int)
The shared timestamp to use for all items to enqueue.
channel_values (Mapping[str, StreamType])
A dictionary mapping channel names to their respective values.
tags (Mapping[str, str] | None)
Key-value tags associated with the data being uploaded.
Note: This should include all
required_tagsconfigured for the dataset.
- enqueue_string_array(channel_name, timestamp, value, tags=None)#
Add an array of strings to the queue after normalizing the timestamp.
- enqueue_struct(channel_name, timestamp, value, tags=None)#
Add a struct (dict) to the queue after normalizing the timestamp.
- Parameters:
- flush(wait=False, timeout=None)#
Flush current batch of records to nominal in a background thread.