TombstoneManager
Manages tombstone retention and purging. Implements spec Section 13 (Tombstone Retention).
public static class TombstoneManager
Methods
CalculateSafePurgeVersion(IEnumerable<SyncClient>)
public static long CalculateSafePurgeVersion(IEnumerable<SyncClient> clients)
Calculates the safe purge version - tombstones below this can be deleted. This is the minimum version that ALL known clients have synced past.
Parameters:
| Name | Type | Description |
|---|---|---|
clients |
SyncClient> |
All tracked client sync states. |
Returns: Int64 - Safe purge version, or 0 if no clients.
RequiresFullResync(long, long)
public static bool RequiresFullResync(long clientLastVersion, long oldestAvailableVersion)
Determines if a client requires full resync (missed tombstones).
Parameters:
| Name | Type | Description |
|---|---|---|
clientLastVersion |
Int64 |
Client's last synced version. |
oldestAvailableVersion |
Int64 |
Oldest version still in sync log. |
Returns: Boolean - True if client needs full resync.
FindStaleClients(IEnumerable<SyncClient>, DateTime, TimeSpan)
public static IReadOnlyList<string> FindStaleClients(IEnumerable<SyncClient> clients, DateTime now, TimeSpan inactivityLimit)
Identifies stale clients that should be removed from tracking.
Parameters:
| Name | Type | Description |
|---|---|---|
clients |
SyncClient> |
All tracked clients. |
now |
DateTime |
Current UTC timestamp. |
inactivityLimit |
TimeSpan |
Max allowed inactivity period. |
Returns: String> - List of client origin IDs to remove.
PurgeTombstones(IEnumerable<SyncClient>, Func<long, Result<int, SyncError>>)
public static Result<int, SyncError> PurgeTombstones(IEnumerable<SyncClient> clients, Func<long, Result<int, SyncError>> purgeTombstones)
Purges tombstones that all clients have synced past.
Parameters:
| Name | Type | Description |
|---|---|---|
clients |
SyncClient> |
All tracked clients. |
purgeTombstones |
SyncError>> |
Function to delete tombstones below version. |
Returns: SyncError> - Number of tombstones purged or error.
UpdateClientSyncState(string, long, string, SyncClient?)
public static SyncClient UpdateClientSyncState(string originId, long syncedToVersion, string timestamp, SyncClient? existingClient)
Updates or creates a client tracking record after successful sync.
Parameters:
| Name | Type | Description |
|---|---|---|
originId |
String |
Client origin ID. |
syncedToVersion |
Int64 |
Version client synced to. |
timestamp |
String |
Current UTC timestamp. |
existingClient |
SyncClient |
Existing client record if any. |
Returns: SyncClient - Updated client record.
CreateFullResyncError(long, long)
public static SyncErrorFullResyncRequired CreateFullResyncError(long clientVersion, long oldestVersion)
Creates a full resync error for a client that has fallen behind.
Parameters:
| Name | Type | Description |
|---|---|---|
clientVersion |
Int64 |
Client's last synced version. |
oldestVersion |
Int64 |
Oldest available version in log. |
Returns: SyncErrorFullResyncRequired - FullResyncRequired error.
Values
| Name | Description |
|---|---|
DefaultClientInactivityLimit |
Default maximum age for inactive clients before removal. |