Skip to content

IPollScheduleStore Interface

Remembers, per polled request, the earliest moment its client may ask again.

C#
public interface IPollScheduleStore

Derived
↳ PollScheduleStore

Remarks

A record of its own rather than a field on the request it belongs to, and that is the whole point. The polling client asks often and the thing it changes is only this instant, while the user's approval changes the request's status - and a poll that wrote the request back to note the instant overwrote an approval that had landed since it read. The user approved, and the device was told to keep waiting until the code expired.

Two polls of the same request can still overwrite each other here, and that is harmless: both write about the same instant, give or take the time between them. What cannot happen any more is a poll writing anything the approval owns.

Absence means the client may ask now, so nothing is written when a request is created. The entry expires with the request it belongs to, which is why every write states the remaining lifetime.

Methods

IPollScheduleStore.SetNextPollAtAsync(string, DateTimeOffset, TimeSpan) Method

Records the earliest moment this request's client may ask again.

C#
System.Threading.Tasks.Task SetNextPollAtAsync(string key, System.DateTimeOffset nextPollAt, System.TimeSpan expiresIn);

Parameters

key System.String

The storage key naming this request's poll schedule.

nextPollAt System.DateTimeOffset

The instant before which the client is told to slow down.

expiresIn System.TimeSpan

What the request it belongs to has left, so the entry cannot outlive it.

Returns

System.Threading.Tasks.Task

IPollScheduleStore.TryGetNextPollAtAsync(string) Method

The earliest moment this request's client may ask again, or null when it may ask now.

C#
System.Threading.Tasks.Task<System.Nullable<System.DateTimeOffset>> TryGetNextPollAtAsync(string key);

Parameters

key System.String

The storage key naming this request's poll schedule.

Returns

System.Threading.Tasks.Task<System.Nullable<System.DateTimeOffset>>
The instant, or null when none is recorded.