ChangeApplier

Classes > Sync > ChangeApplier

Applies changes to the local database with FK violation defer/retry. Implements spec Section 11 (Bi-Directional Sync Protocol).

public static class ChangeApplier

Methods

ApplyBatch(SyncBatch, string, int, Func<SyncLogEntry, Result<bool, SyncError>>, ILogger)

public static Result<BatchApplyResult, SyncError> ApplyBatch(SyncBatch batch, string myOriginId, int maxRetryPasses, Func<SyncLogEntry, Result<bool, SyncError>> applyChange, ILogger logger)

Applies a batch of changes with FK violation handling. Changes are applied in version order. FK violations are deferred and retried.

Parameters:

Name Type Description
batch SyncBatch The batch of changes to apply.
myOriginId String This replica's origin ID (to skip own changes).
maxRetryPasses Int32 Maximum retry passes for deferred changes.
applyChange SyncError>> Function to apply a single change. Returns true on success, false on FK violation.
logger ILogger Logger for change application.

Returns: SyncError> - Result of applying the batch.

IsForeignKeyViolation(string)

public static bool IsForeignKeyViolation(string message)

Determines if an exception represents an FK constraint violation. Platform-specific implementations should override detection logic.

Parameters:

Name Type Description
message String Exception message to check.

Returns: Boolean - True if this is an FK violation.