Skip to main content

Module sync

Module sync 

Source
Expand description

Keeps character sheets in step with combats: hit points are written back, and what casting or using a feature costs (a slot, uses) is spent on the sheet before the command runs and given back if it’s refused or undone. Every frontend gets this without doing anything.

The combat log stays the authority during a fight; the character service follows it. How far each combat has been written back is stored in combat_hp_sync, so a write-back that fails (the character service is down, say) is retried later by whichever instance gets there first. Only one instance syncs a given combat at a time, and it always writes the latest HP, so sheets never go backwards. Spending and giving back carry an idempotency key, so a retry never does either twice.

It writes as this service itself (see crate::services).

Structs§

SheetSync
Keeps character sheets in step with combats: hit points, and slots and uses spent or given back.

Functions§

refused_key
Giving back what a refused command spent.