PgIpLock.onAcquire() method

This would provide a late acquire handler which will be called once the lock is taken over by the retry timer, with the channel name bypassed to a given handler.

Acquiring the lock is only ever half of the caller's job - the other half (issuing LISTEN, in the PgPubSub case) happens right after acquire() returns true. When the first attempt loses to another process, that caller is long gone by the time the timer wins the lock, so without this handler the second half never runs and the lock is held by a process that does nothing with it - forever, since a held lock keeps every other process away too.

Signature:

onAcquire(handler: (channel: string) => void): void;

Parameters

Parameter

Type

Description

handler

(channel: string) => void

called with the channel name when this lock changes hands

Returns:

void

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.