Field Notes
    Preparing search index...

    Interface HubBackend

    interface HubBackend {
        sharedAcrossInstances?: boolean;
        applyElement(
            room: string,
            write: ElementWrite,
            expected: { editor?: string; version: number } | null,
        ): Promise<{ ok: true } | { current: HubRecord | undefined; ok: false }>;
        applyLayerRecord?(room: string, record: LayerRecord): Promise<void>;
        evictRoom?(room: string): Promise<void>;
        getLayerRecord?(room: string, id: string): Promise<LayerRecord | undefined>;
        getRecord(room: string, id: string): Promise<HubRecord | undefined>;
        getService?<T>(key: ServiceKey<T>): T | undefined;
        layerRecords?(room: string): Promise<LayerRecord[]>;
        snapshot(
            room: string,
        ): Promise<{ elements: SyncElement[]; tombstones: StoredTombstone[] }>;
    }

    Implemented by

    Index
    sharedAcrossInstances?: boolean

    True when every hub instance addresses the same atomic backing state (for example Redis).

    • Writes atomically when the stored record's version and editor equal expected (absent equals absent; null: no record may exist). Comparing the editor keeps two instances from both winning an equal-version race. clear ignores it and requires its expected map to match every element exactly. A clear's tombstone ids equal its expected keys; backends should reject one where they differ.

      Parameters

      • room: string
      • write: ElementWrite
      • expected: { editor?: string; version: number } | null

      Returns Promise<{ ok: true } | { current: HubRecord | undefined; ok: false }>

    • Parameters

      • room: string
      • record: LayerRecord

      Returns Promise<void>

    • Called after roomIdleTimeoutMs with no local connection; drops only state held in process memory.

      Parameters

      • room: string

      Returns Promise<void>

    • Parameters

      • room: string
      • id: string

      Returns Promise<LayerRecord | undefined>