pub struct FillGroups { /* private fields */ }Expand description
A run of groups readers miss, for a Requests handler to serve.
It names start.group up to the exclusive end, the first group from
start’s frame. A reader’s time start that no group the cache holds places
asks for the group containing that time as a fill one key wide, from the time, whose first
group may start below it: see floor. Its priority
and order follow its readers as they
change, so read them as each group is served. The handler calls accept for each group
it has and drop_groups for the rest, one group at a time as
poll_wanted_changed yields them, so it writes no faster than its
readers read. Serve the fills you take concurrently: each waits on its own readers, so
serving them in turn holds every fill behind the readers of the one before. Dropping the fill names
whatever is left as dropped while a reader still wants it; once nobody does, the fill is
withdrawn and records nothing, so stop serving it once wanted is None.
A reader narrowing its ranges may leave a single group, so stop serving that one when
poll_unwanted is ready and move on to wanted.
A clone serves the same fill, and the fill is settled once the last clone drops. Each
clone watches on its own, so its first poll_wanted_changed
reports the current value.
Implementations§
Source§impl FillGroups
impl FillGroups
Sourcepub fn start(&self) -> Position
pub fn start(&self) -> Position
The first group to fill, and the frame within it to start from.
Sourcepub fn floor(&self) -> u64
pub fn floor(&self) -> u64
The oldest group the first group may start at: start’s, unless that is a
reader’s time start no group the cache holds places. Then the first group is the one
containing that time: the group starting at it, or else the newest one starting before
it, at or after the floor; once that group ends whole at or before the time, the reader
starts past it, at its End. A handler knowing its groups only by key serves that key as
any other; one that can tell which group holds the time, as from an index, may
accept that group instead, or drop_groups the
key when none does. The reader starts where the answer says, never where the groups
the cache holds happen to say: a drop, or the fill closed unanswered, says no group
starts from the floor through the time, so it starts at the group just below the floor
(at its End once the time is past that group’s span), or past the time when the floor is
0. A refusal fails the reader
with its error until its ranges change.
Sourcepub fn is_time_start(&self) -> bool
pub fn is_time_start(&self) -> bool
Whether it answers a reader’s time start, whose first group is the one containing the
time from the floor through it, even when the floor is the time
itself: a drop then says no group starts there, and a refusal fails the reader.
Sourcepub fn frame_start(&self, key: u64) -> u64
pub fn frame_start(&self, key: u64) -> u64
The frame group key starts from: start’s frame for the first
group, 0 for the rest.
Sourcepub fn priority(&self) -> i8
pub fn priority(&self) -> i8
The most urgent delivery priority among the readers waiting on it now.
Sourcepub fn order(&self) -> Order
pub fn order(&self) -> Order
Which end to fill first now: Order::Descending is newest first.
Sourcepub fn accept(
&self,
key: u64,
info: impl Into<Option<Info>>,
) -> Result<Option<Producer>>
pub fn accept( &self, key: u64, info: impl Into<Option<Info>>, ) -> Result<Option<Producer>>
Insert group key into the track’s cache, handing it to the readers waiting on
it, and return a group::Producer to fill.
On a track this publisher accepted, a group past every one it produced is its live feed, which its subscriptions deliver too; one below is history, served only to whoever misses it. A relay’s copy leaves that to its upstream’s subscription.
The group starts at start’s frame when it is the first group, so the
frames written keep the indices they have in the group. A key from the
floor up to the start’s answers the start with that group, from its
first frame. info sets the track’s Info if it hasn’t been accepted yet (a fetch
with no live subscription), and is ignored otherwise. Returns None if the group was
already answered or cached. Errors with Error::InvalidRange outside the fill,
Error::Skipped if the track skipped it, or the track’s abort error.
A group is named by its frame 0’s timestamp, so on a timed track writing frame 0 at any
other time is Error::TimestampMismatch.
Sourcepub fn drop_groups(&self, groups: Range<u64>)
pub fn drop_groups(&self, groups: Range<u64>)
Name groups as never to be delivered: the source no longer has them. Readers stop
waiting for them, and the track records them so nobody asks again. Only the groups a
reader still reads count; the rest of the fill was never owed.
Sourcepub fn refuse_groups(&self, groups: Range<u64>, err: Error)
pub fn refuse_groups(&self, groups: Range<u64>, err: Error)
Refuse groups with err without saying the source lost them, as when serving them
failed for now or this request asks what the source can’t serve. The readers waiting
now stop waiting, and a later reader asks again. Only the groups a reader still reads
count, as with Self::drop_groups.
Sourcepub fn is_wanted(&self, key: u64) -> bool
pub fn is_wanted(&self, key: u64) -> bool
Whether a reader still waits for group key from this fill: false once every
reader took it or narrowed past it, or nobody waits on the fill. A group stops being
wanted for good; once accepted and taken, group::Producer::demand
says who reads it.
Sourcepub fn poll_unwanted(&self, key: u64, waiter: &Waiter) -> Poll<()>
pub fn poll_unwanted(&self, key: u64, waiter: &Waiter) -> Poll<()>
Resolves once no reader waits for group key from this fill, so stop serving it.
Sourcepub async fn unwanted(&self, key: u64)
pub async fn unwanted(&self, key: u64)
Resolves once no reader waits for group key from this fill, so stop serving it.
Awaits poll_unwanted.
Sourcepub fn wanted(&self) -> Option<u64>
pub fn wanted(&self) -> Option<u64>
The next group still owed in the fill’s order: a reader still reads it, and it was
neither answered nor delivered live since it was asked. None once none is owed or
no reader waits on the fill, so stop serving it. It does not wait for the readers to
take what was served before it; poll_wanted_changed does.
Sourcepub fn poll_wanted_changed(&mut self, waiter: &Waiter) -> Poll<Option<u64>>
pub fn poll_wanted_changed(&mut self, waiter: &Waiter) -> Poll<Option<u64>>
The next group to serve: wanted once it differs from what this handle
last returned and every group this fill answered reached a reader, which picks it up
when it next reads. None once the fill is withdrawn, or answered and taken: keep the
fill until then, since the cache holds what a reader has yet to take only while the
fill lives. The first call returns at once, unless a group already answered has yet to
reach a reader.
So while let Some(key) = fill.wanted_changed().await writes one group at a time
as the fastest reader reads on. The cache holds the first group in the fill’s order that
a reader has yet to take, which no eviction takes before it does: a fill holds at most
one group, however far its readers fall behind, and a reader asks again for any other
it loses. A reader reading in another order than the fill’s picks up groups it cannot
take yet, so the fill moves on.
Sourcepub async fn wanted_changed(&mut self) -> Option<u64>
pub async fn wanted_changed(&mut self) -> Option<u64>
The next group to serve: wanted once it differs from what this handle
last returned and every group this fill answered reached a reader, which picks it up
when it next reads. None once the fill is withdrawn, or answered and taken: keep the
fill until then, since the cache holds what a reader has yet to take only while the
fill lives. The first call returns at once, unless a group already answered has yet to
reach a reader.
So while let Some(key) = fill.wanted_changed().await writes one group at a time
as the fastest reader reads on. The cache holds the first group in the fill’s order that
a reader has yet to take, which no eviction takes before it does: a fill holds at most
one group, however far its readers fall behind, and a reader asks again for any other
it loses. A reader reading in another order than the fill’s picks up groups it cannot
take yet, so the fill moves on.
Awaits poll_wanted_changed.