Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Delayed::Job
Browse files Browse the repository at this point in the history
  • Loading branch information
se3000 committed May 17, 2016
1 parent 230ebb4 commit 2776f0e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gem 'delayed_job_active_record'
gem 'dotenv-rails'
gem 'hashie'
gem 'httparty'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -44,6 +44,11 @@ GEM
coderay (1.1.1)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
delayed_job (4.0.6)
activesupport (>= 3.0, < 5.0)
delayed_job_active_record (4.0.3)
activerecord (>= 3.0, < 5.0)
delayed_job (>= 3.0, < 4.1)
diff-lcs (1.2.5)
dotenv (0.11.1)
dotenv-deployment (~> 0.0.2)
Expand Down Expand Up @@ -165,6 +170,7 @@ PLATFORMS

DEPENDENCIES
byebug
delayed_job_active_record
dotenv-rails
factory_girl_rails
hashie
Expand Down
5 changes: 5 additions & 0 deletions bin/delayed_job
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
22 changes: 22 additions & 0 deletions db/migrate/20160517161413_create_delayed_jobs.rb
@@ -0,0 +1,22 @@
class CreateDelayedJobs < ActiveRecord::Migration
def self.up
create_table :delayed_jobs, force: true do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
end

add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
end

def self.down
drop_table :delayed_jobs
end
end
18 changes: 17 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160516224857) do
ActiveRecord::Schema.define(version: 20160517161413) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -23,6 +23,22 @@
t.datetime "updated_at"
end

create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "handler", null: false
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree

create_table "subscribers", force: :cascade do |t|
t.text "notification_url"
t.string "xid"
Expand Down

0 comments on commit 2776f0e

Please sign in to comment.