Implements a lease renewal service which utilizes a setInterval() based approach to renew leases at regular intervals. The renewal delay is calculated as half the duration of the lease in seconds.

Implements

Constructors

Methods

  • Cancels a scheduled lease renewal. This implementation uses the clearInterval() method to cancel the scheduled lease renewal. Due to the nature of the setInterval()/clearInterval() methods, the scheduled event may still fire at least once after the cancellation.

    Parameters

    • scheduleId: number

      the unique identifier of the scheduled lease renewal. The unique identifier is the ID of the setInterval() timeout.

    Returns Promise<boolean>

    true if the lease renewal was previously scheduled; false otherwise.

  • Cancels all scheduled lease renewals. This implementation cancels all scheduled lease renewals by iterating over the internal registry and clearing each timeout.

    Returns Promise<Map<number, boolean>>

    a map of the unique identifiers of the scheduled lease renewals and their cancellation status.

  • Determines if a lease renewal is scheduled. This implementation uses the internal registry to track all non-cancelled lease renewals.

    Parameters

    • scheduleId: number

      the unique identifier of the scheduled lease renewal.

    Returns Promise<boolean>

    true if the lease renewal is scheduled; false otherwise.

  • Schedules a lease renewal. This implementation uses the setInterval() method to renew the lease at regular intervals.

    Parameters

    • lease: Lease

      the lease to be renewed.

    Returns Promise<number>

    the unique identifier of the scheduled lease renewal. The unique identifier is the ID of the setInterval() timeout.