@litert/[email protected]
该文章根据 CC-BY-4.0 协议发表,转载请遵循该协议。
本文地址:https://fenying.net/en/project/litert/xxl-job-integration.js/v1.0.0/
@litert/xxl-job-integration
is an integration library for the XXL-Job scheduling system for NodeJS, written in TypeScript.
Features
-
Completely flexible and composable
The library is designed to be flexible and composable, allowing you to use only the features you need. And you can replace most of the components with other implementations if you want.
-
Glue Types
-
Write your job handler in NodeJS, so it can be called by the XXL-Job server with a specific handler name.
-
Run a NodeJS script in current process, which can be used to run a job handler written in NodeJS.
This allows you to create extra job handlers without the need to change the executor code.
However, this may cause some RCE vulnerabilities if you use untrusted scripts, so be careful when using this feature.
-
Shell Script
Not yet implemented, but will be available in the future.
-
Python Script
Not yet implemented, but will be available in the future.
-
-
Automatically register the executor to the XXL-Job server and keep it alive.
-
Routing strategies
- FAIL_OVER
- BUSY_OVER
-
Log storage (with rotation support)
-
Built-in: MemoryLogManager
Store the logs in memory, which is suitable for development and testing purposes.
-
Built-in: FileLogManager
Store the logs in files, which is suitable for production environments. It supports log rotation based on file creation time.
-
Custom logs storage
You can also implement your own log storage to store the job logs in a persistent way as you want.
-
Documentation
-
A quick start guide to get you started with the library.
-
The API documentation of the library, including all the classes and methods.
Requirement
-
TypeScript v5.0.0 (or newer)
-
Node.js v18.0.0 (or newer)
-
XXL-Job v3.1.0 (or newer)
The lower versions may work, but they are not tested and not guaranteed to work.
Installation
1npm i @litert/xxl-job-integration --save
Example Usage
- Using
node:http
andFileLogManager
to run a job handler - Using
fastify
andMemoryLogManager
to run a job handler
License
This library is published under Apache-2.0 license.