kue_ruby 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -2
- data/kue_ruby.gemspec +0 -1
- data/lib/kue_ruby.rb +33 -2
- data/lib/kue_ruby/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16ca548bd2deda07050ad7e804647377ef10e413
|
4
|
+
data.tar.gz: cab8f99e8c4dfa6256bb520699af261d89e05ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d71cc6522f387597f5885c85928fa81e21fc4b7ac0cc0fa42df6068f93a5eccec870844c7ce54d74e557ad7a7abad95719ec31ad005ed4fb46e7b9a5502a0e1
|
7
|
+
data.tar.gz: 44f9a62c4787ec481e577c95cf13df9596b995a2eef84cce53274930553cc4cdfe99719e97bd61cbea5d659853a22e97ad0e7bb8f0e4a4b066e8d8e4a1365706
|
data/Gemfile.lock
CHANGED
data/kue_ruby.gemspec
CHANGED
data/lib/kue_ruby.rb
CHANGED
@@ -14,6 +14,7 @@ class KueRuby
|
|
14
14
|
#
|
15
15
|
# @return [KueRuby] a new kue client instance
|
16
16
|
def initialize(options = {})
|
17
|
+
raise(ArgumentError, ':redis Redis required', caller) unless options[:redis]
|
17
18
|
@redis = options[:redis]
|
18
19
|
@prefix = options[:prefix] ? options[:prefix] : 'q'
|
19
20
|
super()
|
@@ -44,6 +45,25 @@ class KueRuby
|
|
44
45
|
#
|
45
46
|
# @return [KueJob] a new kue job
|
46
47
|
def create_job(options = {})
|
48
|
+
raise(ArgumentError, ':type String required', caller) unless options[:type]
|
49
|
+
raise(ArgumentError, ':data Hash required', caller) unless options[:data]
|
50
|
+
begin
|
51
|
+
return create_job! options
|
52
|
+
rescue
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Enqueue a job
|
58
|
+
#
|
59
|
+
# @param Hash options
|
60
|
+
# @option options String :type name of the queue for the job
|
61
|
+
# @option options Hash :data hash of job data
|
62
|
+
# @option options [Integer] :max_attempts max attempts for the job
|
63
|
+
# @option options [Integer] :priority default is 0/normal
|
64
|
+
#
|
65
|
+
# @return KueJob a new kue job, throwing on exception
|
66
|
+
def create_job!(options = {})
|
47
67
|
raise(ArgumentError, ':type String required', caller) unless options[:type]
|
48
68
|
raise(ArgumentError, ':data Hash required', caller) unless options[:data]
|
49
69
|
job = KueJob.new
|
@@ -57,7 +77,7 @@ class KueRuby
|
|
57
77
|
job.id = @redis.incr "#{@prefix}.ids"
|
58
78
|
job.zid = create_fifo job.id
|
59
79
|
@redis.sadd "#{@prefix}:job:types", job.type
|
60
|
-
job.save self
|
80
|
+
job.save! self
|
61
81
|
@redis.zadd("#{@prefix}:jobs", job.priority, job.zid)
|
62
82
|
@redis.zadd("#{@prefix}:jobs:inactive", job.priority, job.zid)
|
63
83
|
@redis.zadd("#{@prefix}:jobs:#{job.type}:inactive", job.priority, job.zid)
|
@@ -80,8 +100,19 @@ class KueRuby
|
|
80
100
|
#
|
81
101
|
# @param KueRuby KueRuby instance with redis connection
|
82
102
|
#
|
83
|
-
# @return [KueJob]
|
103
|
+
# @return [KueJob] the kue job
|
84
104
|
def save(kue)
|
105
|
+
save! kue
|
106
|
+
rescue
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
# Save job data to redis kue
|
111
|
+
#
|
112
|
+
# @param KueRuby KueRuby instance with redis connection
|
113
|
+
#
|
114
|
+
# @return KueJob the kue job, throwing on exception
|
115
|
+
def save!(kue)
|
85
116
|
kue.redis.hmset(
|
86
117
|
"#{kue.prefix}:job:#{id}",
|
87
118
|
'max_attempts', max_attempts.to_i,
|
data/lib/kue_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kue_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Beckman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description: Ruby interface gem for the Automattic Kue Redis store
|
84
70
|
email:
|
85
71
|
- josh@officeluv.com
|