Class BulkWriteReporting
Turns a bulk write's outcome into the log line it deserves, and answers the only two questions a caller actually has about one.
public static class BulkWriteReporting
- Inheritance
-
BulkWriteReporting
- Inherited Members
Remarks
A batched write reports three counts rather than a boolean — see BulkWriteResult — and the two ways rows go missing want opposite treatment. A superseded row is the database telling us it already holds something newer, which is routine under concurrency and not worth a warning on every periodic save. A filtered row is the service telling us it could not act on what we asked for at all, which is never routine and was, before this, entirely silent.
Centralised so that every call site classifies a discrepancy the same way. Spread across twenty hand-written checks, the distinction would survive in some and quietly rot in the rest — which is how it came to be missing in the first place.
Methods
ReportAsync(string, string, DatabaseResult<BulkWriteResult>, string)
Reports a best-effort bulk write: one where the database legitimately holding newer data is an acceptable outcome.
public static Task<bool> ReportAsync(string tag, string operation, DatabaseResult<BulkWriteResult> result, string context = null)
Parameters
tagstringLog source.
operationstringWhat was being written, for the log line.
resultDatabaseResult<BulkWriteResult>The write's outcome.
contextstringOptional extra identification, such as a character ID.
Returns
Remarks
The right call for periodic and despawn saves. A superseded row there means another writer got to it first with a fresher snapshot, so the stored value is the better of the two and there is nothing to repair.
RequireCompleteAsync(string, string, DatabaseResult<BulkWriteResult>, string)
Reports a bulk write that must land in full, failing the caller if it did not.
public static Task<bool> RequireCompleteAsync(string tag, string operation, DatabaseResult<BulkWriteResult> result, string context = null)
Parameters
tagstringLog source.
operationstringWhat was being written, for the log line.
resultDatabaseResult<BulkWriteResult>The write's outcome.
contextstringOptional extra identification, such as a character ID.
Returns
Remarks
The right call for rows that are being created for the first time — a new character's starting inventory, factions and abilities. Nothing newer can exist to supersede them, so a shortfall is not a race: it means rows were dropped, and continuing would hand the player a character that is quietly missing part of itself.