百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

delayed_job_mongoid

> 数据库
开源

用于延迟任务的 Mongoid 后端

169 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于延迟任务的 Mongoid 后端

DelayedJob Mongoid backend

Gem Version Build Status Code Climate Coverage

Requirements

Delayed Job Mongoid supports the following dependency versions:

  • Ruby 2.3+
  • Mongoid 5+

For Mongoid 3 and 4, use 2.x version of this gem.

Installation

Add the gem to your Gemfile:

ruby
gem 'delayed_job_mongoid'

Then create the indexes (don't forget to do this in production):

script/rails runner 'Delayed::Backend::Mongoid::Job.create_indexes'

To generate script/delayed_job:

rails generate delayed_job

That's it. Use delayed_job as normal.

Advanced Usage

Silencing Noisy Logging

By default, the Mongo Ruby Driver will print log lines every 5 seconds as Delayed Job polls your database. Use the following plugin to silence logs which happen while polling (except error level) and only log operations which happen during job execution.

ruby
# in initializers/delayed_job.rb

require 'delayed/plugins/mongo_silencer'
Delayed::Worker.plugins << Delayed::Plugins::MongoSilencer

To ensure thread safety, this plugin requires your Mongo::Logger.logger to be an instance of ActiveSupport::Logger class. It will ignore instances of the Ruby standard library Logger class.

Customizing Job Class

Delayed Job allows specifying a custom backend class for jobs. For example, you may wish to specify a different database collection name. To do this:

ruby
# in an initializer

class MyJob
  include ::Mongoid::Document

  store_in(collection: :my_jobs)

  include ::Delayed::Backend::Mongoid::Mixin
end

Delayed::Worker.backend = MyJob

# in your application

MyJob.enqueue(job_object)

Issues· 1 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubydelayed-jobmongoidmongoid-plugin

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库