Skip to content

Commit

Permalink
Fix typos in timeseries docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist committed Nov 3, 2022
1 parent e2f86c3 commit 1331036
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions site/timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def measureAverageBitrate[F[_]](store: Ref[F, Long], input: Stream[F, Byte]): St

## Time Series

All good, right? But wait, what happens if we stop receiving data for a while? There will be no input to `TimeStamped.withPerSecondRate`, which means there will be no output as well, and that means our `Ref` will not be updated -- it will be frozen with the last value! We need to `Ref` to accurately reflect the loss of data, which means we need some way to all `withPerSecondRate` to emit zero values as time passes.
All good, right? But wait, what happens if we stop receiving data for a while? There will be no input to `TimeStamped.withPerSecondRate`, which means there will be no output as well, and that means our `Ref` will not be updated -- it will be frozen with the last value! We need the `Ref` to accurately reflect the loss of data, which means we need some way to allow `withPerSecondRate` to emit zero values as time passes.

To accomplish this, we can modify our bitrate calculation to operate on values of type `TimeStamped[Option[ByteVector]]`, where a timestamped `None` represents a "tick" of the clock. A stream of timestamped options is referred to as a "time series" and the `fs2.timeseries.TimeSeries` object defines various ways to build such streams.

Expand Down Expand Up @@ -125,4 +125,4 @@ def measureAverageBitrate[F[_]: Temporal](store: Ref[F, Long], input: Stream[F,

In this example, both `bitrate` and `averageBitrate` are instances of `Scan`. The `averageBitrate` function is able to directly reuse `bitrate` via `andThen` to construct a "bigger" scan. After we've finished composing scans, we convert the scan to a pipe and apply it to the input stream (in `measureAverageBitrate`).

There are lots of combinators on `TimeStamped` and `TimeSeries` which provide scans. The `Scan` type also provides many generic combinators.
There are lots of combinators on `TimeStamped` and `TimeSeries` which provide scans. The `Scan` type also provides many generic combinators.

0 comments on commit 1331036

Please sign in to comment.