Status: Observed (in force). Reconstructed.
Context
Local state must stay aligned with the provider in both directions: employee enrolments need pushing out, and withdrawals need pulling back so payroll can recover them and the employer can be invoiced. The options are webhooks from the provider, on-demand sync, or polling.
Decision
Two BackgroundService workers, each polling on a 30-second Task.Delay:
| Worker |
Direction |
Drives |
EwaEmployeeSynchronizationService (118 lines) |
push |
EwaInitialization.IsSynchronized |
EwaWithdrawalSynchronizationService (118 lines) |
pull |
EwaWithdrawal.IsSynchronized |
Both follow the same shape: fetch the unsynchronised set → build a synchronisation model list → call the sync method → flip the flag. A manual Control/Ewa/Sync can force a run.
IsSynchronized is the entire contract between local mirror and provider.
Consequences
Good:
- Simple and robust to transient failures — a missed cycle just retries 30 seconds later, with no webhook endpoint to secure or replay.
- Near-real-time in practice: an enrolment or withdrawal lands within a minute.
- The flag makes backlog directly observable —
IsSynchronized = false and ageing is a clean alert.
Bad / costs:
- Constant load. Two workers polling every 30s per instance run ~2,880 cycles/day each, mostly finding nothing. Multiply by instances.
- Hard retries against a failing provider. During an outage both workers keep hammering at 30s, generating log noise and load precisely when the dependency is unhealthy — there's no visible backoff.
- No idle backoff — cadence doesn't adapt to load, so a quiet tenant costs the same as a busy one.
- Financial consequence when stuck. This isn't stale reporting: an unsynced withdrawal is an advance that payroll won't recover, and an invoice that understates. Sync lag is a money bug. (runbook §2)
If revisited
- Exponential backoff on consecutive failures — the cheapest improvement.