Skip to content

PgOpaqueAdvisoryLocks — @gj-kit/toss-payments-postgresql

A public interface from @gj-kit/toss-payments-postgresql/testing. The signature below is taken directly from the 0.5.1 release declaration.

import { PgOpaqueAdvisoryLocks } from '@gj-kit/toss-payments-postgresql/testing';
/**
* lifecycle work를 short-lived PostgreSQL advisory transaction lock 아래 실행하는 표면.
*
* callback에 SQL session을 전달하지 않는다. 이 API의 목적은 host DB transaction/worker
* lifecycle의 **순서화**이며, 다른 ORM connection의 transaction과 2PC 원자성을 만들지
* 않는다. callback은 local durable work만 수행하고 provider/HTTP 같은 긴 network I/O는
* 넣지 않아야 한다. callback 안에서 같은 key로 이 facility를 재진입하면 다른 connection이
* 바깥 transaction의 xact lock을 기다려 self-deadlock하므로, 연관 작업은 한 callback에 둔다.
*/
interface PgOpaqueAdvisoryLocks {
withLock<T>(key: OpaqueAdvisoryLockKey, operation: () => T | Promise<T>): Promise<T>;
}

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/toss-payments-postgresql
  • Version: 0.5.1
  • Public entry: ./testing
  • Source: GitHub