recurring_active_job 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/config/migrate/20180627123939_create_recurring_active_job.rb +2 -0
- data/config/schema.rb +29 -27
- data/lib/recurring_active_job/base.rb +11 -0
- data/lib/recurring_active_job/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7496f9b7922dc8bb3beb7847d28df78d5d4e810a3a4ef27abcbe9fd92578994
|
4
|
+
data.tar.gz: e6f4de1ab487c438d149a8002a2bfb4fe8d5540efbbe95d11674aa04b615ea2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a26539de51596e643612a685a580ae460cc84821f5bff4d35853cc4d7f04942f747abd25e455c054c242f0aebef90411fe450f0d77eec6227822acbfa292f8
|
7
|
+
data.tar.gz: 00763c972f25777295694d3ead555acb2cac83fe7b347b1f83c170dd96d3303596a28ce0c0e631929e40e52be01a9e056972a97fb125295b19ea2e4f0afc6ed1
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#### Adapter agnostic ActiveJob scheduler based on time spent between executions.
|
4
4
|
|
5
5
|
<!--- Version informartion -->
|
6
|
-
*You are viewing the README of
|
6
|
+
*You are viewing the README of version [v0.2.0](https://github.com/thisismydesign/recurring_active_job/releases/tag/v0.2.0). You can find other releases [here](https://github.com/thisismydesign/recurring_active_job/releases).*
|
7
7
|
<!--- Version informartion end -->
|
8
8
|
|
9
9
|
| Branch | Status |
|
@@ -61,6 +61,8 @@ def change
|
|
61
61
|
t.boolean :active, default: true, null: false
|
62
62
|
t.integer :frequency_seconds, default: 600, null: false
|
63
63
|
t.boolean :auto_delete, default: true, null: false
|
64
|
+
t.string :last_error
|
65
|
+
t.text :last_error_details
|
64
66
|
|
65
67
|
t.timestamps
|
66
68
|
end
|
@@ -6,6 +6,8 @@ class CreateRecurringActiveJob < ActiveRecord::Migration[5.1]
|
|
6
6
|
t.boolean :active, default: true, null: false
|
7
7
|
t.integer :frequency_seconds, default: 600, null: false
|
8
8
|
t.boolean :auto_delete, default: true, null: false
|
9
|
+
t.string :last_error
|
10
|
+
t.text :last_error_details
|
9
11
|
|
10
12
|
t.timestamps
|
11
13
|
end
|
data/config/schema.rb
CHANGED
@@ -1,27 +1,29 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# Note that this schema.rb definition is the authoritative source for your
|
6
|
-
# database schema. If you need to create the application database on another
|
7
|
-
# system, you should be using db:schema:load, not running all the migrations
|
8
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 2018_06_27_123939) do
|
14
|
-
|
15
|
-
create_table "recurring_active_jobs", force: :cascade do |t|
|
16
|
-
t.string "job_id"
|
17
|
-
t.string "provider_job_id"
|
18
|
-
t.boolean "active", default: true, null: false
|
19
|
-
t.integer "frequency_seconds", default: 600, null: false
|
20
|
-
t.boolean "auto_delete", default: true, null: false
|
21
|
-
t.
|
22
|
-
t.
|
23
|
-
t.
|
24
|
-
t.
|
25
|
-
|
26
|
-
|
27
|
-
end
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2018_06_27_123939) do
|
14
|
+
|
15
|
+
create_table "recurring_active_jobs", force: :cascade do |t|
|
16
|
+
t.string "job_id"
|
17
|
+
t.string "provider_job_id"
|
18
|
+
t.boolean "active", default: true, null: false
|
19
|
+
t.integer "frequency_seconds", default: 600, null: false
|
20
|
+
t.boolean "auto_delete", default: true, null: false
|
21
|
+
t.string "last_error"
|
22
|
+
t.text "last_error_details"
|
23
|
+
t.datetime "created_at", null: false
|
24
|
+
t.datetime "updated_at", null: false
|
25
|
+
t.index ["job_id"], name: "index_recurring_active_jobs_on_job_id", unique: true
|
26
|
+
t.index ["provider_job_id"], name: "index_recurring_active_jobs_on_provider_job_id", unique: true
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -6,6 +6,12 @@ module RecurringActiveJob
|
|
6
6
|
attr_accessor :logger
|
7
7
|
end
|
8
8
|
|
9
|
+
retry_on(StandardError, attempts: 0) do |job, e|
|
10
|
+
recurring_active_job = RecurringActiveJob::Model.find(job.arguments.first&.dig(:recurring_active_job_id))
|
11
|
+
recurring_active_job.update!(last_error: "#{e.class}: #{e.message}", last_error_details: ruby_style_error(e))
|
12
|
+
raise e
|
13
|
+
end
|
14
|
+
|
9
15
|
before_enqueue do |job|
|
10
16
|
raise "Missing `recurring_active_job_id` argument" unless job.arguments.first&.dig(:recurring_active_job_id)
|
11
17
|
load_recurring_active_job(job.arguments.first&.dig(:recurring_active_job_id))
|
@@ -65,5 +71,10 @@ module RecurringActiveJob
|
|
65
71
|
def logger
|
66
72
|
self.class.logger
|
67
73
|
end
|
74
|
+
|
75
|
+
def self.ruby_style_error(e)
|
76
|
+
e.backtrace.join("\n\t")
|
77
|
+
.sub("\n\t", ": #{e}#{e.class ? " (#{e.class})" : ''}\n\t")
|
78
|
+
end
|
68
79
|
end
|
69
80
|
end
|