node-rethinkdb-job-queue

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 阎修明
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Introduction

rethinkdb-job-queue is a persistent job or task queue backed by RethinkDB.It has been built as an alternative to the many queues available on NPM.

Thinker

NPM

Please Star on GitHub / NPM and Watch for updates.

Features

Documentation

Quick Start

Installation

Note: You will need to install RethinkDB before you can use rethinkdb-job-queue.

npm install rethinkdb-job-queue --save

See the installation document for supported Node.js versions and workarounds.

Simple Example

const Queue = require('rethinkdb-job-queue')
const qOptions = {
  name: 'Mathematics' // The queue and table name
}
const cxnOptions = {
  db: 'JobQueue', // The name of the database in RethinkDB
}

const q = new Queue(cxnOptions, qOptions)

const job = q.createJob({
  numerator: 123,
  denominator: 456
})

q.process((job, next) => {
    try {
      let result = job.numerator / job.denominator
      // Do something with your result
      return next(null, result)
    } catch (err) {
      console.error(err)
      return next(err)
    }
})

return q.addJob(job).catch((err) => {
  console.error(err)
})

E-Mail Job Example using nodemailer

// The following is not related to rethinkdb-job-queue.
// This is the nodemailer configuration
const nodemailer = require('nodemailer')
const transporter = nodemailer.createTransport({
  service: 'Mailgun',
  auth: {
    user: 'postmaster@superheros.com',
    pass: 'your-api-key-here'
  }
})

// Setup e-mail data with unicode symbols
var mailOptions = {
  from: '"Registration" <support@superheros.com>', // Sender address
  subject: 'Registration', // Subject line
  text: 'Click here to complete your registration', // Plaintext body
  html: '<b>Click here to complete your registration</b>' // HTML body
}

// rethinkdb-job-queue configuration
const Queue = require('rethinkdb-job-queue')

// Queue options have defaults and are not required
const qOptions = {
  name: 'RegistrationEmail', // The queue and table name
  masterInterval: 310000, // Database review period in milliseconds
  changeFeed: true, // Enables events from the database table
  concurrency: 100,
  removeFinishedJobs: 2592000000, // true, false, or number of milliseconds
}

// Connection options have defaults and are not required
// You can replace these options with a rethinkdbdash driver object
const cxnOptions = {
  host: 'localhost',
  port: 28015,
  db: 'JobQueue', // The name of the database in RethinkDB
}

// This is the main queue instantiation call
const q = new Queue(cxnOptions, qOptions)

// Customizing the default job options for new jobs
q.jobOptions = {
  priority: 'normal',
  timeout: 300000,
  retryMax: 3, // Four attempts, first then three retries
  retryDelay: 600000 // Time in milliseconds to delay retries
}

const job = q.createJob()
// The createJob method will only create the job locally.
// It will need to be added to the queue.
// You can decorate the job with any data to be saved for processing
job.recipient = 'batman@batcave.com'

q.process((job, next) => {
  // Send email using job.recipient as the destination address
  mailOptions.to = job.recipient
  return transporter.sendMail(mailOptions).then((info) => {
    console.dir(info)
    return next(null, info)
  }).catch((err) => {
    // This catch is for nodemailer sendMail errors.
    return next(err)
  })
})

return q.addJob(job).then((savedJobs) => {
  // savedJobs is an array of the jobs added with updated properties
}).catch((err) => {
  console.error(err)
})

About the Owner

I, Grant Carthew, am a technologist, trainer, and Dad from Queensland, Australia. I work on code in a number of personal projects and when the need arises I build my own packages.

This project exists because there were no functional job queues built on the RethinkDB database. I wanted an alternative to the other job queues on NPM.

Everything I do in open source is done in my own time and as a contribution to the open source community.

If you are using my projects and would like to thank me or support me, please click the Patreon link below.

See my other projects on NPM.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Want to help but not sure how? Checkout the ideas page.

Please see the debugging and testing documents for more detail.

Credits

Thanks to the following marvelous packages and people for their hard work:

This list could go on...

License

MIT

 相关资料
  • RethinkDB 设计用来存储 JSON 文档的分布式数据库,可通过简单操作实现多机分布式存储。支持表的联合和分组查询。 特点: 简单编程模型 JSON 数据模型和一致性 分布式联合查询、子查询、聚合查询和原子更新操作 Hadoop 风格的 map/reduce. 轻松管理 提供友好的 Web 和命令行管理工具 服务器和网络故障时的谨慎处理 多数据中心复制和故障转移 水平伸缩 数据分片和复制到多

  • 我正在尝试在NIFI中使用PutRethinkDB处理器。 下面是配置的属性。(这是一个测试设置,因此nifi和rethinkdb在同一台机器上,而rethinkdb还没有密码设置)。 运行流时,PutRethinkDB处理器显示以下错误。

  • Job

    Job负责批处理任务,即仅执行一次的任务,它保证批处理任务的一个或多个Pod成功结束。 Job Spec格式 spec.template格式同Pod RestartPolicy仅支持Never或OnFailure 单个Pod时,默认Pod成功运行后Job即结束 .spec.completions标志Job结束需要成功运行的Pod个数,默认为1 .spec.parallelism标志并行运行的Pod

  • 问题内容: 我正在使用node-cron运行计划的作业。我希望作业每隔45分钟运行一次,但操作却很奇怪 这是我正在使用的模式 我的脚本开始于 这是工作执行的前两次 这绝对不是我期望或想要的。我想要的是每45分钟运行一次Jobs。有人可以帮我这个图案吗?谢谢 :) 问题答案: 您可能正在寻找 范围在这里。 秒:0-59 分钟:0-59 时间:0-23 每月的日期:1-31 月:0-11 星期几:0-

  • Job Monarch 是 Ganglia 监控系统的插件,提供了批量作业监控。支持 Torque, PBS, 和 SLURM, 对 LSF 和 SGE 的支持还处于体验阶段。

  • 蓝鲸作业平台(Job)是一套运维脚本管理系统,具备海量任务并发处理能力。除了支持脚本执行、文件分发、定时任务等一系列基础运维场景以外,还支持通过流程调度能力将零碎的单个任务组装成一个自动化作业流程;而每个作业都可做为一个原子节点,提供给上层或周边系统/平台使用,实现跨系统调度自动化。 Benefits 安全可靠的高危命令检测能力 作为底层面向服务器OS的原子操作平台,对用户操作指令是否合规、安全的