Table of Contents

Class WorldClockReading

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

The world clock row as one statement read it, with the database clock it was read against.

public sealed class WorldClockReading
Inheritance
WorldClockReading
Inherited Members

Remarks

WorldMsNow was computed inside the statement, against the same database clock that stamped BaseReferenceMs, so it does not carry the reader's clock skew. A reader that wants to keep the clock moving locally anchors WorldMsNow on its own monotonic clock the moment the reply arrives and advances it at Rate; it must not subtract its own wall clock from BaseReferenceMs.

When Exists is false, no scene server has seeded the row yet. Only DbNowMs is meaningful then; every other field is zero or null.

Constructors

WorldClockReading(bool, long, long, long, double, double, long, long, string?, DateTime?, long, long?, double?)

Creates a reading. Used by the service; a caller has no reason to build one.

public WorldClockReading(bool exists, long dbNowMs, long baseWorldMs, long baseReferenceMs, double rate, double resumeRate, long epochUnixSeconds, long revision, string? updatedBy, DateTime? updatedAt, long worldMsNow, long? replacedWorldMs = null, double? replacedRate = null)

Parameters

exists bool
dbNowMs long
baseWorldMs long
baseReferenceMs long
rate double
resumeRate double
epochUnixSeconds long
revision long
updatedBy string
updatedAt DateTime?
worldMsNow long
replacedWorldMs long?
replacedRate double?

Properties

BaseReferenceMs

Database Unix milliseconds when the base was written.

public long BaseReferenceMs { get; }

Property Value

long

BaseWorldMs

World milliseconds since the calendar epoch at BaseReferenceMs.

public long BaseWorldMs { get; }

Property Value

long

DbNowMs

The database clock, Unix milliseconds, as the statement read it.

public long DbNowMs { get; }

Property Value

long

EpochUnixSeconds

The calendar epoch, Unix seconds. World timestamp = this instant + world ms.

public long EpochUnixSeconds { get; }

Property Value

long

Exists

Whether the row exists. False until a scene server has seeded it.

public bool Exists { get; }

Property Value

bool

IsHeld

Whether the clock is held (pace zero).

public bool IsHeld { get; }

Property Value

bool

Rate

World seconds per real second: 0 held, 1 real time, above 1 raced.

public double Rate { get; }

Property Value

double

ReplacedRate

On the reading a write returns: the pace the write replaced. Null as for ReplacedWorldMs.

public double? ReplacedRate { get; }

Property Value

double?

ReplacedWorldMs

On the reading a WRITE returns: the world time the write replaced, at the same database instant as DbNowMs. Null on a plain read, and on a write that was a replay (its first attempt committed, the reply was lost, and the retry found its own idempotency key on the row — the write happened exactly once, and what it replaced is no longer known).

public long? ReplacedWorldMs { get; }

Property Value

long?

ResumeRate

The pace a resume returns to.

public double ResumeRate { get; }

Property Value

double

Revision

Incremented on every write; a new revision is adopted as an instant jump.

public long Revision { get; }

Property Value

long

UpdatedAt

UTC time of the last write, by the database clock; null for the seed.

public DateTime? UpdatedAt { get; }

Property Value

DateTime?

UpdatedBy

Account that made the last write; null for the seed.

public string? UpdatedBy { get; }

Property Value

string

WorldMsNow

World milliseconds since the epoch at DbNowMs: base_world_ms + rate × max(0, db_now_ms − base_reference_ms), floored.

public long WorldMsNow { get; }

Property Value

long

Methods

Missing(long)

A reading of a database that has no world clock row yet.

public static WorldClockReading Missing(long dbNowMs)

Parameters

dbNowMs long

Returns

WorldClockReading