본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)25k · #10094

nocobase-app-plugin-concurrency

하는 일

이 스킬은 NocoBase 3 앱의 프로세스 로컬 잠금 서비스를 설정합니다. 두 작업이 같은 것을 동시에 바꾸지 않도록 막아야 하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓두 요청이 같은 레코드를 동시에 바꿀 수 있을 때.
  • ✓NocoBase 서버 코드에 이름이 있는 잠금이 필요할 때.
  • ✓애플리케이션 설정 파일에서 잠금 설정을 구성하고 싶을 때.

스킬 링크

https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-concurrency/skills/nocobase-app-plugin-concurrency/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-concurrency/skills/nocobase-app-plugin-concurrency/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“두 사용자가 재고 업데이트를 동시에 실행하지 못하도록 제 NocoBase 앱에 잠금을 추가해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 동시성 플러그인을 등록하고, 설정에 이름이 있는 잠금 관리자를 구성하며, 잠금이 필요한 코드에서 잠금 서비스를 사용합니다. 이 잠금은 실행 중인 하나의 프로세스 안에서 작동합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Concurrency

Install and register

Install @nocobase/app-plugin-concurrency with compatible application-supplied @nocobase/app-server, @nocobase/service-provider and @nocobase/concurrency peers. Register the default /server definition before business plugins and register defineConcurrencyConfig() from /config under concurrency. Installation and both registrations are separate requirements.

The factory supplies default: memory and memory.adapter: mutex, declares CONCURRENCY_DEFAULT and exposes no browser fields. Entry fields are adapter, optional namespace (application name by default), optional ttl, and implementation-owned connection. Mutex forbids connection. TTL is a renewable lease duration, an integer from 1 through 2147483647 milliseconds. Local Mutex accepts and validates TTL but ignores it, with no holding timer, expiration release or local renewal. Resource TTL overrides configuration TTL; undefined retains configuration TTL. Unknown options and invalid selectors fail. Entries do not inherit from one another. Two enabled local entries cannot share a namespace.

Consume the original service

import { concurrencyServiceToken } from '@nocobase/app-plugin-concurrency/server';

const service = app.container.resolve(concurrencyServiceToken);
// Obtain managers in ready or normal running work.
const manager = await service.getManager();
const executor = await manager.createSynchronous('orders:sync');
const result = await executor.tryRun(async () => 'done', 500);

Inject the owner-created Token; never create a second Token or service. The same configuration name shares one manager. Same-name Lock and Executor handles compete in the same domain regardless of TTL. Use bounded, stable resource names: the local native Mutex table remains until instance shutdown. Local locks coordinate only within that instance, never across processes.

lock and run wait without a deadline until success, cancellation or failure. Omitted/zero positional try budgets use native tryAcquire, including its zero-millisecond timer window. Positive try budgets use native withTimeout, not a precise return deadline. Busy results come only from explicit native non-acquisition. Capture each call's signal once; cancellation before delivery must not affect other waiters. Cancellation after delivery does not release a Lease or stop a runner. Late native success after cancellation is released using its own releaser without delivery, runner execution or TTL timer.

Lease release is asynchronous and idempotent; concurrent calls share a result and failures permit explicit retry on the same handle while its instance remains usable. Executors combine Lock acquisition with a no-argument runner, wait for actual runner settlement and diagnose cleanup failure without replacing business values or exceptions. Local Mutex remains held beyond an explicit TTL until manual release, actual runner settlement or instance shutdown. TTL is not a runner timeout or a validity guarantee. Redis implementations use native automatic renewal for both Lock and Executor, not an Executor-owned renewal loop. Use application transactions and idempotency where required.

Lifecycle and extensions

The Provider owns initialization and shutdown. Default startup is eager; named configurations initialize lazily and concurrently share one initialization. Boot freezes the complete snapshot, including unused entries. Reload requires restart to apply changes and never changes active or lazy domains.

Applications stop dependent business work before Concurrency shutdown. Shutdown rejects new acquisitions, interrupts waits, observes issued native requests and actively releases confirmed Leases without draining runners. Release failures are diagnosed while cleanup continues. Concurrent shutdown shares a Promise and successful shutdown is idempotent. Failed owned-resource closure retains its handle for explicit owner service.shutdown() retry. A second app.shutdown() does not repeat cached Provider shutdown. No public operation, cleanup or overall shutdown deadline is configured.

Implementation authors use /server: ManagedLeaseRegistry, startAcquire, createSynchronousExecutor, encodeResourceKey and the original implementation/configuration types. The registry registers confirmed releasers synchronously and owns only Lease release and record disposal, not acquisition, pending work, TTL or renewal. `startAcquire(registry, { si

자주 묻는 질문

잠금이 여러 서버에 걸쳐 작동하나요?

로컬 잠금은 한 프로세스 안에서만 작동하며, 스킬은 그 한계를 설명합니다.

잠금에 제한 시간을 줄 수 있나요?

생존 시간 설정은 받아들여지지만, 로컬 잠금은 이를 사용하지 않습니다.

잠금이 데이터베이스에 저장되나요?

아니요. 애플리케이션 프로세스 안의 잠금 서비스입니다.

상세 정보

작성자의 원본 설명

Configure and consume NocoBase 3 process-local Mutex locks, strict named managers, original service Token, optional TTL, public implementation extensions and application-owned shutdown.

repo: nocobase/nocobase

인기도

GitHub 스타
25k
순위
#10094
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬