H5P NodeJS Library
    Preparing search index...

    Offers locking a mechanism to prevent race conditions.

    interface ILockProvider {
        acquire<T>(
            key: string,
            callback: () => Promise<T>,
            options: { maxOccupationTime: number; timeout: number },
        ): Promise<T>;
    }

    Implemented by

    Index

    Methods

    Methods

    • Type Parameters

      • T

      Parameters

      • key: string

        the key of the resource to lock

      • callback: () => Promise<T>

        the code which should run once the lock was acquired

      • options: { maxOccupationTime: number; timeout: number }
        • maxOccupationTime: number

          how long to wait until the code in callback is finished

        • timeout: number

          how long to wait until the lock is acquired

      Returns Promise<T>

      'timeout' or 'occupation-time-exceed' errors