feat: add account-scoped data synchronization

This commit is contained in:
2026-09-22 09:58:58 +08:00
parent ab9ff389f2
commit 72e040546a
37 changed files with 4252 additions and 159 deletions
@@ -27,6 +27,13 @@ public sealed class ServiceOptions
public bool EnableValidationOperations { get; init; }
public bool EnableListenerEvents { get; init; }
public bool PreventAutoLock { get; init; }
// Database-backed platform sync is opt-in until its source/account mapping has passed shadow validation.
public bool EnableDataSync { get; init; }
public int DataSyncIntervalSeconds { get; init; } = 5;
public int DataSyncBatchLimit { get; init; } = 100;
public int DataSyncOverlapRows { get; init; } = 1;
public int DataSyncQueueMaxItems { get; init; } = 1000;
public long DataSyncQueueMaxBytes { get; init; } = 16 * 1024 * 1024;
// Kept only so older service.json files can be loaded and rewritten by the tray.
[JsonIgnore]
@@ -48,6 +55,14 @@ public sealed class ServiceOptions
throw new ArgumentException("External HTTP requires a concrete listen IP; do not use 0.0.0.0 or ::.");
if (AccessToken is not null && !IsValidAccessToken(AccessToken))
throw new ArgumentException("AccessToken must be non-empty and contain no whitespace.");
if (DataSyncIntervalSeconds is < 1 or > 300)
throw new ArgumentException("DataSyncIntervalSeconds must be between 1 and 300.");
if (DataSyncBatchLimit is < 1 or > 500)
throw new ArgumentException("DataSyncBatchLimit must be between 1 and 500.");
if (DataSyncOverlapRows is < 0 or > 100)
throw new ArgumentException("DataSyncOverlapRows must be between 0 and 100.");
if (DataSyncQueueMaxItems is < 1 or > 100_000 || DataSyncQueueMaxBytes is < 1 or > 512L * 1024 * 1024)
throw new ArgumentException("Data sync queue limits are out of range.");
try
{
Remote?.Validate();