Table of Contents

Class DaemonCommandExpiry

Namespace
FishMMO.Database.Data
Assembly
FishMMO-DB.dll

Whether a claimed daemon command may still be executed, judged without the daemon's wall clock.

public static class DaemonCommandExpiry
Inheritance
DaemonCommandExpiry
Inherited Members

Remarks

A command is stamped, claimed and completed by the database clock. A daemon that compared the command's deadline with its own UtcNow measured the skew between its host and the database along with the time left: one running five minutes fast refused every command it was given (five minutes is the lifetime), and one running slow executed commands after the operator had stopped waiting for them.

So the claim returns the seconds left, measured by the database in the statement that claimed the row (ExpiresInSeconds), and the daemon counts them down on a monotonic clock, which no wall-clock step, correction or time-zone change can move. The daemon anchors that count when it SENDS the claim, not when the reply arrives: the database measured somewhere in between, so an early anchor can only overstate the time elapsed. Every error is therefore toward refusing, because a restart carried out after its requester stopped waiting is the failure this check exists to prevent.

Methods

IsExpired(double?, TimeSpan)

Whether a claimed command must be refused as expired.

public static bool IsExpired(double? expiresInSecondsAtClaim, TimeSpan sinceClaimSent)

Parameters

expiresInSecondsAtClaim double?

See SecondsLeft(double?, TimeSpan).

sinceClaimSent TimeSpan

See SecondsLeft(double?, TimeSpan).

Returns

bool

Remarks

Exactly zero left is expired: the claim takes a row only while expires_utc > now, so this is the same boundary seen from the daemon.

SecondsLeft(double?, TimeSpan)

Seconds still left: the database's measurement at the claim, less the time that has passed since the claim was sent.

public static double SecondsLeft(double? expiresInSecondsAtClaim, TimeSpan sinceClaimSent)

Parameters

expiresInSecondsAtClaim double?

ExpiresInSeconds from the claim, or null when nothing was measured.

sinceClaimSent TimeSpan

Monotonic time since the claim was sent. Negative counts as zero: elapsed time can never extend a deadline.

Returns

double

The seconds left; zero or less is expired. Negative infinity when nothing was measured, so a command with no measured deadline is never run.