Logo Hor Renchan Job Bullmq

Hor Renchan Job Bullmq

Tổ chức
openreachtech
hor-renchan-job-bullmq

Write and wire background jobs with @openreachtech/renchan-job-bullmq (BullMQ on Redis). Use this skill whenever the user asks to add or edit a job under app/jobs/** — a Manifest / Worker / Dispatcher triple, a cron or interval (repeatable) job, enqueuing from a GraphQL/REST resolver, publishing progress to a GraphQL subscription, the worker daemon entry point, splitting work across queues, tuning concurrency / retries / rate limits, the queue's Redis policy, or duplicate guards.

Add to TypingMind

Tổng quan

Nhà phát hànhopenreachtech
Kho mãhora-skills-ort-renchan
Tên kỹ nănghor-renchan-job-bullmq
Sao
32
Bản fork
0
Tệp đi kèm
5
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được openreachtech công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hor Renchan Job Bullmq trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-renchan-job-bullmq
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openreachtech/hora-skills-ort-renchan.git /tmp/hora-skills-ort-renchan
mkdir -p .claude/skills
cp -r /tmp/hora-skills-ort-renchan/kit/skills/hor-renchan-job-bullmq .claude/skills/hor-renchan-job-bullmq
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Hor Renchan Job Bullmq trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Hor Renchan Job Bullmq ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Hor Renchan Job Bullmq với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

renchan-job-bullmq

@openreachtech/renchan-job-bullmq is this repo's job framework: BullMQ queues on Redis, wrapped in renchan base classes. A job is a small template of class files in one directory under app/jobs/<job-name>/. Two long-running processes share one Redis (pm2.config.cjs):

  • GraphQL API (server/index.js) — handles requests and enqueues jobs (producer).
  • Job Daemon (scripts/startJobDaemon.js) — runs the workers (consumer) and publishes progress back over Redis PubSub to the API's GraphQL subscriptions.

This overview maps each topic to a section; the specifics are in the detail files under references/. The package's own usage samples live in samples/confirm-01 (dispatch + daemon) and samples/confirm-02 (cron + interval schedulers) of the hor-renchan-job-bullmq package.

Core principle: a job is a filled-in template of 3–4 files

Each job is a directory app/jobs/<kebab-job-name>/ holding a fixed set of classes, each extending a renchan base, all pointing at one central Engine:

FileBase classResponsibility
<Name>JobManifest.jsBaseJobManifestthe queue name (jobName) + the body schema
<Name>JobWorker.jsBaseJobWorkerconsume: executeJob() + lifecycle hooks
<Name>JobDispatcher.jsBaseJobDispatcherproduce: enqueue + per-queue optionHash
<Name>CronJobScheduler.js / <Name>IntervalJobScheduler.jsBaseCronJobScheduler / BaseIntervalJobScheduler(scheduled jobs) register a repeatable job

Keep the layout identical across jobs so review attention goes to the job's logic. Directory = kebab = jobName; classes are PascalCase with those fixed suffixes. Structural comments are English; the domain-explanation comments in the real files are Japanese (they cite the plan, T-JOB-*) — match the surrounding code.

1. Basic usage — the Manifest / Worker / Dispatcher triple

  • Manifest — jobName (the queue name, == the directory) + bodySchema (ScalarHash scalars Text / Integer / … from @openreachtech/mentsu-schema). Keep the body minimal (ids/tokens).
  • Worker — static get ManifestCtor() + async executeJob({ body, context, parcel }) + the four abstract lifecycle hooks (onJobCompleted / onJobFailed / onJobProgress / onWorkerError). executeJob's return value is stored in Redis — return only the minimum, never entity arrays. Override buildOptionHash() for concurrency / limiter.
  • Dispatcher — static get EngineCtor() + static get ManifestCtor() + optional static get optionHash() (BullMQ QueueOptions, e.g. defaultJobOptions.attempts). To stay DRY, a base app dispatcher can set EngineCtor once so each job dispatcher only sets ManifestCtor.
js
// Manifest — the source of truth for the queue name and payload shape
export default class SendReportEmailJobManifest extends BaseJobManifest {
  /** @override */ static get jobName () { return 'send-report-email' }

  /** @override */
  static get bodySchema () {
    return {
      sessionToken: Text,
    }
  }
}

Enqueue from a resolver via the request-scope JobDispatcherProvider (connection reuse):

js
await context.share.jobDispatcherProvider.dispatchJob({
  DispatcherCtor: SendReportEmailJobDispatcher,
  body: {
    sessionToken,
  },
})

Standalone (one-off): const dispatcher = await Dispatcher.createAsync(); await dispatcher.dispatchJob({ body }); await dispatcher.teardown() — dispatchJob returns a response with hasError() / hasResponse() / createDispatchedAt().

Full classes, hooks, the base-app-dispatcher pattern, and the enqueue paths are in job-triple.md.

2. Engine / Share / Context / RedisConnection

  • Engine (ContentGenerationJobEngine.js) — the one config object: config = { workersPath, schedulersPath, redisConfig } (both paths point at app/jobs), plus ShareCtor / ContextCtor, error codes, log path. createAsync({ subscriptionBroker }) injects the progress broker (§4).
  • Share is the per-process DI (holds subscriptionBroker or null, env, timber, …). It is the only class that imports env.
  • Context — per-job DI, created for each run and passed to executeJob.
  • RedisConnection (app/queue/RedisConnection.js) is created by the Share with the env (ContentGenerationJobShare.createRedisConnection()), and gives generateConnectionOptions() for BullMQ (maxRetriesPerRequest: null required) and generatePubSubOptions() for the broker. API and Daemon must share one Redis. That Redis must run with maxmemory-policy noeviction; an evicting policy corrupts the queues.

Details and the package-exports table are in engine-and-infra.md.

3. Entry points — the worker Daemon and the scheduler

Worker Daemon — JobWorkersDaemon auto-discovers every BaseJobWorker under workersPath (DeepBulkClassLoader), binds each to its jobName, and installs graceful SIGINT/SIGTERM shutdown. Two boot shapes:

  • Simple (no progress broker): JobWorkersDaemon.createAsync({ EngineCtor }).then(daemon => daemon.startDaemon()).
  • With a broker (this repo, scripts/startJobDaemon.js): build a SubscriptionBroker, inject it via Engine.createAsync({ subscriptionBroker }), then JobWorkersDaemon.loadWorkerCtors({ engine }) → .create({ engine, WorkerCtors }).startDaemon().

Scheduler registration is a one-shot script (scripts/start-schedule.js): SchedulerService.createAsync({ EngineCtor }) → startAllSchedulers() → exit. It writes repeatable jobs to Redis; the Daemon consumes them. stopAllSchedulers() removes them without stopping the Daemon.

pm2 (pm2.config.cjs) runs GraphQL API and Job Daemon.

Both boot paths, cron and interval schedulers, and the start/stop scripts are in daemon-and-scheduler.md.

4. Integrating with subscriptions (progress → GraphQL)

A worker in the Daemon publishes progress on a channel namespaced by a scope; a GraphQL subscription in the API process subscribes with the same channel + scope, over the shared Redis PubSub broker.

  • The Daemon injects the broker (§3, Path B); enqueue-only processes pass none → publish is a no-op.
  • AI workers get this automatically from BaseAgentJobWorker; the app base BaseContentGenerationJobWorker.js sets channel = 'reportProgress' and buildScope (accessToken else jobId).
  • The subscriber (OnReportProgressSubscriptionResolver.js) must match the channel and scope. This is why the public-lp queue body carries accessToken (§5).

The publish/subscribe wiring and checklist are in subscriptions.md.

5. Splitting queues

One queue == one job directory == one Manifest jobName. The repo splits the same content-generation work into content-generation-internal ({ jobId }) and content-generation-public-lp ({ jobId, accessToken }) so they scale and subscribe independently.

  • Share logic via an app base worker, but place that base OUTSIDE workersPath — the Daemon boots every BaseJobWorker under app/jobs, and an abstract base without a jobName crashes startup. Only concrete workers go under app/jobs/**.
  • Run a subset of queues per Daemon with skipJobHash ({ [jobName]: true }).
  • Tune per queue: Dispatcher optionHash (attempts) + Worker buildOptionHash() (concurrency, limiter).

Details and the directory diagram are in queues.md.

6. Other building blocks

  • Cron / interval jobs — BaseCronJobScheduler ({ cronExpression }) or BaseIntervalJobScheduler ({ millisecond, isImmediately }), listed in SchedulerService.collectScheduleInputs() with a schedulerId matching the scheduler class. See daemon-and-scheduler.md.
  • Connection reuse — JobDispatcherProvider (app/tools/JobDispatcherProvider.js) caches one Dispatcher per DispatcherCtor and dispatches with keepsConnection: true; the request Share holds one, torn down on process exit. Prefer it over Dispatcher.createAsync() per request.
  • Retries & idempotency — set attempts in optionHash; make executeJob idempotent (BullMQ may re-run). Expensive AI jobs checkpoint to content_generations.intermediate_steps_json and resume on retry. onJobFailed fires on every failed attempt, so treat a job as finally failed only when jobModel.job.finishedOn is a number, never by comparing attemptsMade with attempts (job-triple.md).
  • Duplicate guard: to keep identical requests from enqueuing twice, pass optionHash: { deduplication: { id } } to dispatchJob rather than a custom jobId (job-triple.md).
  • Concurrency & rate limiting — buildOptionHash() forwards concurrency + limiter (app/tools/ContentGenerationRateLimiter.js).
  • Testing — unit-test workers/dispatchers with the hoc-jest skill.

Detail files

  • job-triple.md — Manifest / Worker / Dispatcher in full, body schema, lifecycle hooks, the return-value-in-Redis rule, base-app-dispatcher DRY, enqueue paths (§1)
  • engine-and-infra.md — Engine config, Share, Context, RedisConnection, package exports (§2)
  • daemon-and-scheduler.md — JobWorkersDaemon (both boot paths), scripts/*, cron + interval schedulers, the scheduler service, pm2 (§3, §6)
  • subscriptions.md — progress publish/subscribe, channel + scope, AI-worker plumbing (§4)
  • queues.md — splitting queues, shared-base placement, skipJobHash, per-queue tuning (§5)

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Hor Renchan Job Bullmq làm được gì?

Write and wire background jobs with @openreachtech/renchan-job-bullmq (BullMQ on Redis). Use this skill whenever the user asks to add or edit a job under app/jobs/** — a Manifest / Worker / Dispatcher triple, a cron or interval (repeatable) job, enqueuing from a GraphQL/REST resolver, publishing progress to a GraphQL subscription, the worker daemon entry point, splitting work across queues, tuning concurrency / retries / rate limits, the queue's Redis policy, or duplicate guards.

Vì sao nên dùng Hor Renchan Job Bullmq trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hor Renchan Job Bullmq là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hor Renchan Job Bullmq trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-renchan-job-bullmq. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hor Renchan Job Bullmq?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Hor Renchan Job Bullmq với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hor Renchan Job Bullmq với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hor Renchan Job Bullmq có miễn phí không?

Có. Kỹ năng này được openreachtech phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇