LocalSecondary class

Contains methods to execute verb on local secondary storage using executeVerb Set AtClientPreference.isLocalStoreRequired to true and other preferences that your app needs. Delete and Update commands will be synced to the server

Constructors

LocalSecondary(AtClient _atClient, {AtKeyValueStore<String, AtData, AtMetaData?>? keyStore, void onEvent(DataEvent)?})

Properties

atChopsKeys → AtChopsKeys?
no setter
enrollment ↔ Enrollment?
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
keyStore ↔ AtKeyValueStore<String, AtData, AtMetaData?>?
Local keystore used to store data for the current atSign. Commit-log-free (keyStore.commitLog == null): client bundles track sync via AtSyncQueue + the synced-commit-id watermark, not the commit log.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
syncQueueForTest → Future<AtSyncQueue>
Test seam — production code goes through the public API above. Direct access to the queue lets tests inject pre-populated state, assert on persistence-layer behaviour, or close the queue without tearing down the whole LocalSecondary.
no setter
syncQueueSize → Future<int>
Number of atKeys with pending client→server writes. Reads the in-memory queue length (no Hive I/O). Triggers a one-time open of the queue on first call.
no setter
syncQueueSyncSnapshot → int?
Synchronous, side-effect-free snapshot of the current queue size. Returns null when the queue hasn't been opened yet (the caller hasn't done any sync-eligible writes). Used by SyncServiceImpl._informSyncProgress to attach pendingPushCount to events without awaiting (which would change the relative ordering of progress emission and the sync round it describes). Production callers that don't mind the lazy-open should use syncQueueSize instead.
no setter
writesInProgressForTest → Set<String>
Immutable snapshot of the in-progress writes set. Test-only seam — production code consults isWriteInProgress per key.
no setter

Methods

deleteExpiredKeys() → Future<int>
Deletes every key currently flagged expired by the underlying keystore's TTL bookkeeping. Each deletion goes through _delete, which fires a DataDeleted on AtClient.dataEvents — so subscribers see expirations the same way they see any other delete. Returns the number of keys removed.
dropAvailabilityCacheEntry(String key) → Future<void>
Records that the available-timer sweep just emitted DataUpdated for key, so subsequent sweeps don't re-fire for the same availableAt crossing. A subsequent _update that rewrites the record with a new future availableAt (different from the recorded one) re-enables firing.
executeVerb(VerbBuilder builder, {bool? sync, bool cameFromServer = false}) → Future<String?>
Executes a verb builder on the local secondary.
getEncryptionPrivateKey() → Future<String?>
get it from atChops if we have it, otherwise try the keystore
getEncryptionPublicKey(String atSign) → Future<String?>
get it from atChops if we have it, otherwise try the keystore
getEncryptionSelfKey() → Future<String?>
get it from atChops if we have it, otherwise try the keystore
getPkamPrivateKey() → Future<String?>
get it from atChops if we have it, otherwise try the keystore
getPkamPublicKey() → Future<String?>
get it from atChops if we have it, otherwise try the keystore
getPrivateKey() → Future<String?>
getPublicKey() → Future<String?>
isEnrollmentAuthorizedForOperation(String key, VerbBuilder verbBuilder) → Future<bool>
isWriteInProgress(String atKey) → bool
True if a _update or _delete for atKey is currently executing on this LocalSecondary. Synchronous, cheap. Consulted by SyncServiceImpl._syncFromServer per pull entry.
keysWithAvailableAtAtOrBefore(DateTime cutoff) → Future<List<String>>
Keys whose availableAt is at-or-before cutoff and that haven't already been fired for the same crossing (_firedAvailableAt). Drives AtClientImpl._onAvailableFire's visibility-onset sweep.
nextAvailableAt() → Future<DateTime?>
Earliest pending future availableAt across keys with TTB, or null if none. Delegates to AtKeyValueStore.nextAvailableAt, which only considers not-yet-born keys (availableAt > now) — so already-fired past crossings are excluded by construction, with no need to consult _firedAvailableAt.
nextExpiryAt() → Future<DateTime?>
Earliest pending expiresAt across keys with TTL, or null if none. Delegates to KeyValueStore.nextExpiresAt, answered from the backend's expiry index (not a full-store scan).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peekSyncQueue({int? limit}) → Future<List<String>>
Returns up to limit atKey strings from the front of the pending-write queue in FIFO order. Does NOT remove them; the caller is expected to call removeFromSyncQueue per atKey after a successful push.
putValue(String key, String value) → Future<bool>
Returns true on successfully storing the values into local secondary.
readSyncQueueEntry(String atKey) → Future<SyncQueueEntry?>
Reads the persisted record (op + ts) for atKey, or null if no record exists. Used by SyncServiceImpl when building the outgoing batch — the atKey itself comes from peekSyncQueue, the op tells us whether to build update / delete / etc.
removeFromSyncQueue(String atKey) → Future<void>
Removes atKey from both the in-memory queue and the persisted box. Called after a successful server-side push, OR when a drain attempt finds the underlying keystore value missing (race-tolerated removal: a queue write may have committed without the keystore write landing, e.g. across a crash).
seedAvailabilityFiredAsOf(DateTime now) → Future<void>
Pre-marks every key whose availableAt is at or before now as "already fired" in the in-memory _firedAvailableAt map. The availability sweep (AtClientImpl._onAvailableFire) checks this map and skips matching entries, so this prevents the sweep from replaying historical availableAt crossings on every process start.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

shouldEnqueueForSync(String atKey, SyncQueueOp op) → bool
Predicate: should a write to atKey (with operation op) be enqueued for client→server sync? Returns true for self / shared / public / reserved keys (the last covers publickey.<sharedWith>@me and shared_key.<sharedWith>@me which the encryption layer needs to reach the recipient).