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 viaAtSyncQueue+ 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
nullwhen the queue hasn't been opened yet (the caller hasn't done any sync-eligible writes). Used bySyncServiceImpl._informSyncProgressto attachpendingPushCountto 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
DataUpdatedforkey, so subsequent sweeps don't re-fire for the sameavailableAtcrossing. A subsequent_updatethat rewrites the record with a new futureavailableAt(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
_updateor_deleteforatKeyis currently executing on this LocalSecondary. Synchronous, cheap. Consulted bySyncServiceImpl._syncFromServerper pull entry. -
keysWithAvailableAtAtOrBefore(
DateTime cutoff) → Future< List< String> > -
Keys whose
availableAtis at-or-beforecutoffand that haven't already been fired for the same crossing (_firedAvailableAt). DrivesAtClientImpl._onAvailableFire's visibility-onset sweep. -
nextAvailableAt(
) → Future< DateTime?> -
Earliest pending future
availableAtacross keys with TTB, ornullif none. Delegates toAtKeyValueStore.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
expiresAtacross keys with TTL, ornullif none. Delegates toKeyValueStore.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
limitatKey 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
trueon 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 bySyncServiceImplwhen 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
atKeyfrom 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
availableAtis at or beforenowas "already fired" in the in-memory_firedAvailableAtmap. The availability sweep (AtClientImpl._onAvailableFire) checks this map and skips matching entries, so this prevents the sweep from replaying historicalavailableAtcrossings 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 operationop) be enqueued for client→server sync? Returns true for self / shared / public / reserved keys (the last coverspublickey.<sharedWith>@meandshared_key.<sharedWith>@mewhich the encryption layer needs to reach the recipient).