Skillpedia
واجهات API والخوادم (backend)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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-concurrency/skills/nocobase-app-plugin-concurrency/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هل يمكنك إضافة قفل يمنع مستخدمَين من تنفيذ تحديث المخزون في الوقت نفسه في تطبيق NocoBase الخاص بي؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يسجل الذكاء الاصطناعي إضافة concurrency، ويضبط مديري الأقفال المسماة في الإعدادات، ويستخدم خدمة القفل في الشيفرة التي تحتاجها. ويعمل القفل داخل عملية تشغيل واحدة.

المحتوى التقني (ملف 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
الترخيص
—
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة