disc 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -22
- data/lib/disc/version.rb +1 -1
- data/lib/disc.rb +0 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ffe5775ac38d2ed07abc9c602d02bece9ed62be
|
4
|
+
data.tar.gz: 3bb2ef3b149eedcfe99f15ea8b5a9c2a5bfcdc47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d2f921456d0843e97101bda9a408db66ecd9bac51c961edddcfb05ca330a71d447354bf3fe9d805daa6ac65358aae51bd56d248edfd721cf0c541758bca8e7
|
7
|
+
data.tar.gz: a6ca018282b0c2d773424d823524e48814b67d67c1e7272baf8cedc6dbb70825fc0a6aed5bc6f2d8452516ee6e02476f102b0265987df176acc707857e0852fa
|
data/README.md
CHANGED
@@ -83,30 +83,9 @@ end
|
|
83
83
|
Dir["./jobs/**/*.rb"].each { |job| require job }
|
84
84
|
```
|
85
85
|
|
86
|
-
## Lifecycle Callbacks
|
87
|
-
|
88
|
-
You can optionally define two methods on classes that include `Disc::Job` that
|
89
|
-
will act as callbacks:
|
90
|
-
|
91
|
-
``` ruby
|
92
|
-
def disc_start(job)
|
93
|
-
end
|
94
|
-
|
95
|
-
def disc_done(exception_or_nil)
|
96
|
-
end
|
97
|
-
```
|
98
|
-
|
99
|
-
Before the `perform` method is invoked, Disc will call `disc_start` and pass the
|
100
|
-
job data as a Hash. After the job is finished, it will call `disc_done`.
|
101
|
-
|
102
|
-
You could use these callbacks for things like aggregating metrics about the jobs
|
103
|
-
(timing, number of times a certain job is run, etc), or for advanced logging,
|
104
|
-
for example.
|
105
|
-
|
106
86
|
## Job Definition
|
107
87
|
|
108
|
-
|
109
|
-
the current job as a Hash, that has the following schema.
|
88
|
+
The error handler function gets the data of the current job as a Hash, that has the following schema.
|
110
89
|
|
111
90
|
| | |
|
112
91
|
|:-------------:|:------------------------------------------------------|
|
data/lib/disc/version.rb
CHANGED
data/lib/disc.rb
CHANGED
@@ -72,17 +72,10 @@ class Disc
|
|
72
72
|
job = MessagePack.unpack(serialized_job)
|
73
73
|
job.update('id' => msgid, 'queue' => queue)
|
74
74
|
instance = Object.const_get(job['class']).new
|
75
|
-
instance.disc_start(job)
|
76
75
|
instance.perform(*job['arguments'])
|
77
76
|
disque.call('ACKJOB', msgid)
|
78
77
|
rescue => err
|
79
78
|
Disc.on_error(err, job)
|
80
|
-
ensure
|
81
|
-
begin
|
82
|
-
instance.disc_done(err)
|
83
|
-
rescue => boom
|
84
|
-
Disc.on_error(boom, job)
|
85
|
-
end
|
86
79
|
end
|
87
80
|
end
|
88
81
|
end
|
@@ -98,12 +91,6 @@ class Disc
|
|
98
91
|
base.extend(ClassMethods)
|
99
92
|
end
|
100
93
|
|
101
|
-
def disc_start(job)
|
102
|
-
end
|
103
|
-
|
104
|
-
def disc_done(error = nil)
|
105
|
-
end
|
106
|
-
|
107
94
|
module ClassMethods
|
108
95
|
def disque
|
109
96
|
defined?(@disque) ? @disque : Disc.disque
|