kue_ruby 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a7ef81e78f3103b8b2e89756641fe6b0ef8e194
4
- data.tar.gz: 97cca0f205ab8efae8e1bb02df07db5846e09be5
3
+ metadata.gz: 16ca548bd2deda07050ad7e804647377ef10e413
4
+ data.tar.gz: cab8f99e8c4dfa6256bb520699af261d89e05ff0
5
5
  SHA512:
6
- metadata.gz: 3a153d3f1dbdadc972e2bdb93a42f3f2040eae9bc93a628abb9f7edcc1d0d5c8bfe4c5d660a8b032fff57ce227dfe173c5f8293747a462fdb153331c6009d720
7
- data.tar.gz: 3f787785064b73b3c7294adbc4d36058b1af5e9967df40f96fac307ff3d9910d2f36874e69dd4d1a5d518a554cc7ce3aa8979bfee9897643a302e102727c1dec
6
+ metadata.gz: 7d71cc6522f387597f5885c85928fa81e21fc4b7ac0cc0fa42df6068f93a5eccec870844c7ce54d74e557ad7a7abad95719ec31ad005ed4fb46e7b9a5502a0e1
7
+ data.tar.gz: 44f9a62c4787ec481e577c95cf13df9596b995a2eef84cce53274930553cc4cdfe99719e97bd61cbea5d659853a22e97ad0e7bb8f0e4a4b066e8d8e4a1365706
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kue_ruby (0.2.0)
4
+ kue_ruby (0.3.0)
5
5
  redis (~> 4.0.0)
6
6
 
7
7
  GEM
@@ -35,7 +35,6 @@ PLATFORMS
35
35
  DEPENDENCIES
36
36
  bundler (~> 1.13)
37
37
  kue_ruby!
38
- pry
39
38
  rake (~> 10.0)
40
39
  rspec (~> 3.0)
41
40
 
@@ -35,5 +35,4 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'bundler', '~> 1.13'
36
36
  spec.add_development_dependency 'rake', '~> 10.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
38
- spec.add_development_dependency 'pry'
39
38
  end
@@ -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,
@@ -1,3 +1,3 @@
1
1
  class KueRuby
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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.2.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-22 00:00:00.000000000 Z
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