SessionLock

interface SessionLock

A single-active-session guard for a DocStore-backed document. Ported from yorkie-js-sdk session-lock.ts (2291bf67/#1338). Two sessions concurrently resuming the same persisted document under the same stable actor would mint colliding clientSeq values and silently lose edits, so Client takes a lease named after the document before restoring its persisted envelope.

acquire must not block: contention is reported by returning null (fail fast) rather than suspending until the lock frees up, so a contended attach fails immediately instead of hanging.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun acquire(name: String): SessionLockHandle?

Attempts to acquire the lock identified by name. Returns a SessionLockHandle on success, or null if name is already held elsewhere.