-
Notifications
You must be signed in to change notification settings - Fork 20
Description
What's needed?
There are cases when using the Resampler class where the input data is not received via a channel. In this cases just creating a channel to be able to feed the Resampler is inconvenient and inefficient.
Proposed solution
There are several possible solutions that I can think of:
- Move the handling of channels to the resampling actor and have the resampler just take samples by calling a new function, for example:
resampler.add_sample(timeseries_name, sample). - Make the
Resamplerhave 2 methods,add_timeseries(name, source)which still takes an async iterator as it is now, andsource = add_timeseries(name)which returns a source object where you can send samples viasource.add_sample(sample). - Change the resampler to only provide a
source = add_timeseries(name)and refactor the_StreamHelperto make it public and take asourcereturned by theadd_timeseries()function, likeStreamHelper(source, async_iterator), so each time new data comes from an async iterator (receiving in a task), it will callsource.add_sample(sample).
I think 1 is the simplest but less flexible, 3 is the best design because of the flexibility, although a bit more complicated to use, and 2 is in the middle of both.
Looking at this, I'm starting to feel that we should have a resampler that don't work on channels at all, it makes things more complicated (an inefficient) to go through a channel here, where you could have just call resampler.add(sample) when handling the data:
async for sample in self._resampled_data_recv:
log.debug("Received new sample: %s", sample)
if self._resampler:
self._reampler.add(sample)
else:
self._buffer.update(sample)There is already a _ResampleHelper to handle the resampling of only one metric, but it doesn't run its own timer, so we would need to have something that does handle its own timer and ideally can resample multiple metrics.
Use cases
MovingWindow: Update MovingWindow to add resampler #272 (comment)
Alternatives and workarounds
- Create a channel.
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status