resque-remora 0.1.0 → 0.2.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 +7 -0
- data/.travis.yml +15 -0
- data/Gemfile +5 -5
- data/LICENSE.txt +4 -1
- data/README.rdoc +5 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/resque/plugins/remora/push_pop.rb +37 -5
- data/resque-remora.gemspec +36 -34
- data/spec/redis-test.conf +10 -88
- data/spec/resque/plugins/remora/push_pop_spec.rb +5 -5
- data/spec/resque/plugins/remora_spec.rb +9 -8
- data/spec/spec_helper.rb +7 -3
- metadata +113 -139
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b3e9511b071fa39cd707ae05c01c057db81d75dcb25b9403f925dc00b872e34d
|
4
|
+
data.tar.gz: 0d95bb1107f6e0f30a6b9e824645a05c3b676761deef7fcecb2da378225b2cb1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9777121489c3c075773a13d47c3e5a439beb500f9c8e485c8d23b82fbc425870e2115f0e15d7a452f37167c0041264ea211613a2b912aa001c80ad0ef8d060df
|
7
|
+
data.tar.gz: 3044f09ac21d705b1a921d0ef64ba2040fb1b6557ba906d343337f5b9de7be83cf13c147c98bafa5df5004f368957ddc4ae4e87bd10bc3da163879a17e7dfc22
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0-p598
|
5
|
+
- 2.1.5
|
6
|
+
- 2.2.1
|
7
|
+
- ruby-head
|
8
|
+
- jruby-head
|
9
|
+
- jruby-9.0.0.0.pre1
|
10
|
+
- jruby-1.7.19
|
11
|
+
- jruby-18mode # JRuby in 1.8 mode
|
12
|
+
- jruby-19mode # JRuby in 1.9 mode
|
13
|
+
- rbx-19mode
|
14
|
+
- rbx-2
|
15
|
+
- rbx-2.2.7
|
data/Gemfile
CHANGED
@@ -3,10 +3,10 @@ source "http://rubygems.org"
|
|
3
3
|
gem 'resque', "~> 1.10"
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem "rspec"
|
7
|
-
gem "bundler"
|
8
|
-
gem "jeweler"
|
9
|
-
gem "
|
10
|
-
gem "yajl-ruby", "~>
|
6
|
+
gem "rspec"
|
7
|
+
gem "bundler"
|
8
|
+
gem "jeweler"
|
9
|
+
gem "simplecov", ">= 0"
|
10
|
+
gem "yajl-ruby", "~>1.2", :platforms => :mri
|
11
11
|
gem "json", "~>1.5.3", :platforms => :jruby
|
12
12
|
end
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
Original work copyright (c) 2011 nolan frausto
|
2
|
+
|
3
|
+
The code in Resque::Plugins::Remora::PushPop::constantize is from the Rails source
|
4
|
+
Copyright © 2004-2013 David Heinemeier Hansson
|
2
5
|
|
3
6
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
7
|
a copy of this software and associated documentation files (the
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Resque Remora
|
2
2
|
|
3
|
-
Resque Remora is a plugin for the Resque queueing system (http://github.com/defunkt/resque) that allows you to attach a hash with whatever information you want to resque jobs when they are enqueued (much like how a remora attaches to a shark... perhaps.), and then to get that information back and process it whenever the job is taken off the queue. Also of note is that the hash is attached directly to the job so it can be viewed in Redis when looking at queued jobs.
|
3
|
+
Resque Remora is a plugin for the Resque queueing system (http://github.com/defunkt/resque) that allows you to add information to the payload of each enqueued job. It allows you to attach a hash with whatever information you want to resque jobs when they are enqueued (much like how a remora attaches to a shark... perhaps.), and then to get that information back and process it whenever the job is taken off the queue. Also of note is that the hash is attached directly to the job so it can be viewed in Redis when looking at queued jobs.
|
4
4
|
|
5
5
|
== Usage
|
6
6
|
|
@@ -16,7 +16,10 @@ For Example:
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def process_remora(queue, attachment)
|
19
|
-
#do whatever I want with this hash attachment
|
19
|
+
#do whatever I want with this hash attachment.
|
20
|
+
#For example:
|
21
|
+
#time_started = attachment['time'].to_i
|
22
|
+
#time_in_queue = Time.now - Time.at(time_started)
|
20
23
|
end
|
21
24
|
|
22
25
|
#rest of your Job class here
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -10,7 +10,7 @@ module Resque
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
module ClassMethods
|
13
|
+
module ClassMethods
|
14
14
|
def push(queue, item)
|
15
15
|
job_class = constantize(item[:class])
|
16
16
|
item = job_class.remora_attachment.merge(item) if remora_class?(job_class)
|
@@ -19,7 +19,7 @@ module Resque
|
|
19
19
|
|
20
20
|
def pop(queue)
|
21
21
|
job = original_pop(queue)
|
22
|
-
begin
|
22
|
+
begin
|
23
23
|
attachment = job['remora']
|
24
24
|
job_class = constantize(job['class'])
|
25
25
|
if !attachment.nil? && remora_class?(job_class)
|
@@ -29,14 +29,46 @@ module Resque
|
|
29
29
|
end
|
30
30
|
job
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
private
|
34
|
-
|
34
|
+
|
35
35
|
def remora_class?(job_class)
|
36
36
|
job_class && job_class.respond_to?(:process_remora) && job_class.respond_to?(:attach_remora) && job_class.respond_to?(:remora_attachment)
|
37
37
|
end
|
38
|
+
|
39
|
+
# From file activesupport/lib/active_support/inflector/methods.rb, line 226
|
40
|
+
def constantize(camel_cased_word)
|
41
|
+
names = camel_cased_word.split('::')
|
42
|
+
|
43
|
+
# Trigger a builtin NameError exception including the ill-formed constant in the message.
|
44
|
+
Object.const_get(camel_cased_word) if names.empty?
|
45
|
+
|
46
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
47
|
+
names.shift if names.size > 1 && names.first.empty?
|
48
|
+
|
49
|
+
names.inject(Object) do |constant, name|
|
50
|
+
if constant == Object
|
51
|
+
constant.const_get(name)
|
52
|
+
else
|
53
|
+
candidate = constant.const_get(name)
|
54
|
+
next candidate if constant.const_defined?(name, false)
|
55
|
+
next candidate unless Object.const_defined?(name)
|
56
|
+
|
57
|
+
# Go down the ancestors to check it it's owned
|
58
|
+
# directly before we reach Object or the end of ancestors.
|
59
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
60
|
+
break const if ancestor == Object
|
61
|
+
break ancestor if ancestor.const_defined?(name, false)
|
62
|
+
const
|
63
|
+
end
|
64
|
+
|
65
|
+
# owner is in Object, so raise
|
66
|
+
constant.const_get(name, false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
38
70
|
end
|
39
71
|
end
|
40
72
|
end
|
41
73
|
end
|
42
|
-
end
|
74
|
+
end
|
data/resque-remora.gemspec
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: resque-remora 0.2.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
8
|
+
s.name = "resque-remora".freeze
|
9
|
+
s.version = "0.2.0"
|
9
10
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["nolan frausto".freeze]
|
14
|
+
s.date = "2018-09-25"
|
15
|
+
s.description = "resque plugin that allows you to attach information when a job is put in redis, and to do whatever you want with the information when it is popped off the resque queue".freeze
|
16
|
+
s.email = "nrfrausto@gmail.com".freeze
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE.txt",
|
17
19
|
"README.rdoc"
|
@@ -19,6 +21,7 @@ Gem::Specification.new do |s|
|
|
19
21
|
s.files = [
|
20
22
|
".document",
|
21
23
|
".rspec",
|
24
|
+
".travis.yml",
|
22
25
|
"Gemfile",
|
23
26
|
"LICENSE.txt",
|
24
27
|
"README.rdoc",
|
@@ -34,40 +37,39 @@ Gem::Specification.new do |s|
|
|
34
37
|
"spec/spec_helper.rb",
|
35
38
|
"spec/support/jobs.rb"
|
36
39
|
]
|
37
|
-
s.homepage =
|
38
|
-
s.licenses = [
|
39
|
-
s.
|
40
|
-
s.
|
41
|
-
s.summary = %q{resque plugin that allows you to attach information to a resque job and retrieve it when it gets popped of the queue}
|
40
|
+
s.homepage = "http://github.com/frausto/resque-remora".freeze
|
41
|
+
s.licenses = ["MIT".freeze]
|
42
|
+
s.rubygems_version = "2.7.6".freeze
|
43
|
+
s.summary = "resque plugin that allows you to attach information to a resque job and retrieve it when it gets popped of the queue".freeze
|
42
44
|
|
43
45
|
if s.respond_to? :specification_version then
|
44
|
-
s.specification_version =
|
46
|
+
s.specification_version = 4
|
45
47
|
|
46
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<resque
|
48
|
-
s.add_development_dependency(%q<rspec
|
49
|
-
s.add_development_dependency(%q<bundler
|
50
|
-
s.add_development_dependency(%q<jeweler
|
51
|
-
s.add_development_dependency(%q<
|
52
|
-
s.add_development_dependency(%q<yajl-ruby
|
53
|
-
s.add_development_dependency(%q<json
|
49
|
+
s.add_runtime_dependency(%q<resque>.freeze, ["~> 1.10"])
|
50
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<yajl-ruby>.freeze, ["~> 1.2"])
|
55
|
+
s.add_development_dependency(%q<json>.freeze, ["~> 1.5.3"])
|
54
56
|
else
|
55
|
-
s.add_dependency(%q<resque
|
56
|
-
s.add_dependency(%q<rspec
|
57
|
-
s.add_dependency(%q<bundler
|
58
|
-
s.add_dependency(%q<jeweler
|
59
|
-
s.add_dependency(%q<
|
60
|
-
s.add_dependency(%q<yajl-ruby
|
61
|
-
s.add_dependency(%q<json
|
57
|
+
s.add_dependency(%q<resque>.freeze, ["~> 1.10"])
|
58
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
60
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
61
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
62
|
+
s.add_dependency(%q<yajl-ruby>.freeze, ["~> 1.2"])
|
63
|
+
s.add_dependency(%q<json>.freeze, ["~> 1.5.3"])
|
62
64
|
end
|
63
65
|
else
|
64
|
-
s.add_dependency(%q<resque
|
65
|
-
s.add_dependency(%q<rspec
|
66
|
-
s.add_dependency(%q<bundler
|
67
|
-
s.add_dependency(%q<jeweler
|
68
|
-
s.add_dependency(%q<
|
69
|
-
s.add_dependency(%q<yajl-ruby
|
70
|
-
s.add_dependency(%q<json
|
66
|
+
s.add_dependency(%q<resque>.freeze, ["~> 1.10"])
|
67
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
68
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
69
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
70
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
71
|
+
s.add_dependency(%q<yajl-ruby>.freeze, ["~> 1.2"])
|
72
|
+
s.add_dependency(%q<json>.freeze, ["~> 1.5.3"])
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
data/spec/redis-test.conf
CHANGED
@@ -46,10 +46,10 @@ timeout 300
|
|
46
46
|
# warning (only very important / critical messages are logged)
|
47
47
|
loglevel debug
|
48
48
|
|
49
|
-
# Specify the log file name. Also
|
49
|
+
# Specify the log file name. Also the empty string can be used to force
|
50
50
|
# Redis to log on the standard output. Note that if you use standard
|
51
51
|
# output for logging but daemonize, logs will be sent to /dev/null
|
52
|
-
logfile
|
52
|
+
logfile ""
|
53
53
|
|
54
54
|
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
|
55
55
|
# and optionally update the other syslog parameters to suit your needs.
|
@@ -99,9 +99,9 @@ dbfilename dump.rdb
|
|
99
99
|
#
|
100
100
|
# The DB will be written inside this directory, with the filename specified
|
101
101
|
# above using the 'dbfilename' configuration directive.
|
102
|
-
#
|
102
|
+
#
|
103
103
|
# Also the Append Only File will be created inside this directory.
|
104
|
-
#
|
104
|
+
#
|
105
105
|
# Note that you must specify a directory here, not a file name.
|
106
106
|
dir ./spec/
|
107
107
|
|
@@ -142,7 +142,7 @@ slave-serve-stale-data yes
|
|
142
142
|
#
|
143
143
|
# This should stay commented out for backward compatibility and because most
|
144
144
|
# people do not need auth (e.g. they run their own servers).
|
145
|
-
#
|
145
|
+
#
|
146
146
|
# Warning: since Redis is pretty fast an outside user can try up to
|
147
147
|
# 150k passwords per second against a good box. This means that you should
|
148
148
|
# use a very strong password otherwise it will be very easy to break.
|
@@ -196,14 +196,14 @@ slave-serve-stale-data yes
|
|
196
196
|
|
197
197
|
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
|
198
198
|
# is reached? You can select among five behavior:
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# volatile-lru -> remove the key with an expire set using an LRU algorithm
|
201
201
|
# allkeys-lru -> remove any key accordingly to the LRU algorithm
|
202
202
|
# volatile-random -> remove a random key with an expire set
|
203
203
|
# allkeys->random -> remove a random key, any key
|
204
204
|
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
|
205
205
|
# noeviction -> don't expire at all, just return an error on write operations
|
206
|
-
#
|
206
|
+
#
|
207
207
|
# Note: with all the kind of policies, Redis will return an error on write
|
208
208
|
# operations, when there are not suitable keys for eviction.
|
209
209
|
#
|
@@ -249,7 +249,7 @@ appendonly no
|
|
249
249
|
# appendfilename appendonly.aof
|
250
250
|
|
251
251
|
# The fsync() call tells the Operating System to actually write data on disk
|
252
|
-
# instead to wait for more data in the output buffer. Some OS will really flush
|
252
|
+
# instead to wait for more data in the output buffer. Some OS will really flush
|
253
253
|
# data on disk, some other OS will just try to do it ASAP.
|
254
254
|
#
|
255
255
|
# Redis supports three different modes:
|
@@ -287,92 +287,14 @@ appendfsync everysec
|
|
287
287
|
# the same as "appendfsync none", that in pratical terms means that it is
|
288
288
|
# possible to lost up to 30 seconds of log in the worst scenario (with the
|
289
289
|
# default Linux settings).
|
290
|
-
#
|
290
|
+
#
|
291
291
|
# If you have latency problems turn this to "yes". Otherwise leave it as
|
292
292
|
# "no" that is the safest pick from the point of view of durability.
|
293
293
|
no-appendfsync-on-rewrite no
|
294
294
|
|
295
|
-
################################ VIRTUAL MEMORY ###############################
|
296
|
-
|
297
|
-
# Virtual Memory allows Redis to work with datasets bigger than the actual
|
298
|
-
# amount of RAM needed to hold the whole dataset in memory.
|
299
|
-
# In order to do so very used keys are taken in memory while the other keys
|
300
|
-
# are swapped into a swap file, similarly to what operating systems do
|
301
|
-
# with memory pages.
|
302
|
-
#
|
303
|
-
# To enable VM just set 'vm-enabled' to yes, and set the following three
|
304
|
-
# VM parameters accordingly to your needs.
|
305
|
-
|
306
|
-
vm-enabled no
|
307
|
-
# vm-enabled yes
|
308
|
-
|
309
|
-
# This is the path of the Redis swap file. As you can guess, swap files
|
310
|
-
# can't be shared by different Redis instances, so make sure to use a swap
|
311
|
-
# file for every redis process you are running. Redis will complain if the
|
312
|
-
# swap file is already in use.
|
313
|
-
#
|
314
|
-
# The best kind of storage for the Redis swap file (that's accessed at random)
|
315
|
-
# is a Solid State Disk (SSD).
|
316
|
-
#
|
317
|
-
# *** WARNING *** if you are using a shared hosting the default of putting
|
318
|
-
# the swap file under /tmp is not secure. Create a dir with access granted
|
319
|
-
# only to Redis user and configure Redis to create the swap file there.
|
320
|
-
vm-swap-file /tmp/redis.swap
|
321
|
-
|
322
|
-
# vm-max-memory configures the VM to use at max the specified amount of
|
323
|
-
# RAM. Everything that deos not fit will be swapped on disk *if* possible, that
|
324
|
-
# is, if there is still enough contiguous space in the swap file.
|
325
|
-
#
|
326
|
-
# With vm-max-memory 0 the system will swap everything it can. Not a good
|
327
|
-
# default, just specify the max amount of RAM you can in bytes, but it's
|
328
|
-
# better to leave some margin. For instance specify an amount of RAM
|
329
|
-
# that's more or less between 60 and 80% of your free RAM.
|
330
|
-
vm-max-memory 0
|
331
|
-
|
332
|
-
# Redis swap files is split into pages. An object can be saved using multiple
|
333
|
-
# contiguous pages, but pages can't be shared between different objects.
|
334
|
-
# So if your page is too big, small objects swapped out on disk will waste
|
335
|
-
# a lot of space. If you page is too small, there is less space in the swap
|
336
|
-
# file (assuming you configured the same number of total swap file pages).
|
337
|
-
#
|
338
|
-
# If you use a lot of small objects, use a page size of 64 or 32 bytes.
|
339
|
-
# If you use a lot of big objects, use a bigger page size.
|
340
|
-
# If unsure, use the default :)
|
341
|
-
vm-page-size 32
|
342
|
-
|
343
|
-
# Number of total memory pages in the swap file.
|
344
|
-
# Given that the page table (a bitmap of free/used pages) is taken in memory,
|
345
|
-
# every 8 pages on disk will consume 1 byte of RAM.
|
346
|
-
#
|
347
|
-
# The total swap size is vm-page-size * vm-pages
|
348
|
-
#
|
349
|
-
# With the default of 32-bytes memory pages and 134217728 pages Redis will
|
350
|
-
# use a 4 GB swap file, that will use 16 MB of RAM for the page table.
|
351
|
-
#
|
352
|
-
# It's better to use the smallest acceptable value for your application,
|
353
|
-
# but the default is large in order to work in most conditions.
|
354
|
-
vm-pages 134217728
|
355
|
-
|
356
|
-
# Max number of VM I/O threads running at the same time.
|
357
|
-
# This threads are used to read/write data from/to swap file, since they
|
358
|
-
# also encode and decode objects from disk to memory or the reverse, a bigger
|
359
|
-
# number of threads can help with big objects even if they can't help with
|
360
|
-
# I/O itself as the physical device may not be able to couple with many
|
361
|
-
# reads/writes operations at the same time.
|
362
|
-
#
|
363
|
-
# The special value of 0 turn off threaded I/O and enables the blocking
|
364
|
-
# Virtual Memory implementation.
|
365
|
-
vm-max-threads 4
|
366
295
|
|
367
296
|
############################### ADVANCED CONFIG ###############################
|
368
297
|
|
369
|
-
# Hashes are encoded in a special way (much more memory efficient) when they
|
370
|
-
# have at max a given numer of elements, and the biggest element does not
|
371
|
-
# exceed a given threshold. You can configure this limits with the following
|
372
|
-
# configuration directives.
|
373
|
-
hash-max-zipmap-entries 512
|
374
|
-
hash-max-zipmap-value 64
|
375
|
-
|
376
298
|
# Similarly to hashes, small lists are also encoded in a special way in order
|
377
299
|
# to save a lot of space. The special representation is only used when
|
378
300
|
# you are under the following limits:
|
@@ -393,7 +315,7 @@ set-max-intset-entries 512
|
|
393
315
|
# that is rhashing, the more rehashing "steps" are performed, so if the
|
394
316
|
# server is idle the rehashing is never complete and some more memory is used
|
395
317
|
# by the hash table.
|
396
|
-
#
|
318
|
+
#
|
397
319
|
# The default is to use this millisecond 10 times every second in order to
|
398
320
|
# active rehashing the main dictionaries, freeing memory when possible.
|
399
321
|
#
|
@@ -10,22 +10,22 @@ describe Resque::Plugins::Remora::PushPop do
|
|
10
10
|
|
11
11
|
describe "#push" do
|
12
12
|
it "should add the remora information to the end of the job" do
|
13
|
-
TestJob.stub(:remora_attachment => {:remora => {:time => @now, :olah => "oh hai!"}})
|
13
|
+
TestJob.stub(:remora_attachment => {:remora => {:time => @now.to_i, :olah => "oh hai!"}})
|
14
14
|
Resque.enqueue(TestJob, "arg1")
|
15
|
-
Resque.redis.lindex("queue:test",0).should =~ /^\{.*\"remora\":(\{\"olah\":\"oh hai!\",\"time\":\"#{@now}\"\}||\{\"time\":\"#{@now}\",\"olah\":\"oh hai!\"\})/
|
15
|
+
Resque.redis.lindex("queue:test",0).should =~ /^\{.*\"remora\":(\{\"olah\":\"oh hai!\",\"time\":\"#{@now.to_i}\"\}||\{\"time\":\"#{@now.to_i}\",\"olah\":\"oh hai!\"\})/
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#pop" do
|
20
20
|
before do
|
21
|
-
@attachment = {:remora => {:time => @now, :olah => "oh hai!"}}
|
22
|
-
@pop_result = {"args"=>["arg1"], "class"=>"TestJob", "remora"=>{"time"=>@now.
|
21
|
+
@attachment = {:remora => {:time => @now.to_i, :olah => "oh hai!"}}
|
22
|
+
@pop_result = {"args"=>["arg1"], "class"=>"TestJob", "remora"=>{"time"=>@now.to_i, "olah"=>"oh hai!"}}
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should get the remora information for processing" do
|
26
26
|
TestJob.stub(:remora_attachment => @attachment)
|
27
27
|
Resque.enqueue(TestJob, "arg1")
|
28
|
-
TestJob.should_receive(:process_remora).with("test", {'time' => @now.
|
28
|
+
TestJob.should_receive(:process_remora).with("test", {'time' => @now.to_i, 'olah' => "oh hai!"})
|
29
29
|
Resque.pop("test").should == @pop_result
|
30
30
|
end
|
31
31
|
|
@@ -2,38 +2,39 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Resque::Plugins::Remora do
|
4
4
|
subject { Resque::Plugins::Remora }
|
5
|
-
|
5
|
+
|
6
6
|
before do
|
7
7
|
@now = Time.now
|
8
8
|
Time.stub(:now => @now)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should be a valid resque plugin" do
|
12
12
|
Resque::Plugin.lint(Resque::Plugins::Remora)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
describe "#process_remora" do
|
16
|
-
|
16
|
+
|
17
17
|
before do
|
18
18
|
@worker = Resque::Worker.new(:test)
|
19
|
+
@worker.term_child = true
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
it "should process a remora job" do
|
22
23
|
Resque.enqueue(TestJob, "arg1")
|
23
24
|
@worker.work(0)
|
24
25
|
Resque.redis.get("time").should == @now.to_i.to_s
|
25
26
|
Resque.redis.get("queue").should == "test"
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
it "should process multiple remora jobs with different arguments" do
|
29
30
|
Resque.enqueue(TestJob, "arg1")
|
30
31
|
now2 = Time.now
|
31
32
|
Time.stub(:now => now2)
|
32
33
|
Resque.enqueue(TestJob, "arg2")
|
33
|
-
|
34
|
+
|
34
35
|
@worker.work(0)
|
35
36
|
Resque.redis.get(@now.to_i).should == "true"
|
36
37
|
Resque.redis.get(now2.to_i).should == "true"
|
37
38
|
end
|
38
39
|
end
|
39
|
-
end
|
40
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,10 +24,14 @@ dir = File.dirname(__FILE__)
|
|
24
24
|
#
|
25
25
|
|
26
26
|
at_exit do
|
27
|
-
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
28
|
-
puts "Killing test redis server [#{pid}]..."
|
29
27
|
`rm -f #{dir}/dump.rdb`
|
30
|
-
|
28
|
+
pid = `ps -e -o pid,command | grep [r]edis.*9736`.split(" ")[0]
|
29
|
+
if pid.to_i >= 100
|
30
|
+
puts "Killing test redis server [#{pid}]..."
|
31
|
+
Process.kill("KILL", pid.to_i)
|
32
|
+
else
|
33
|
+
puts "Found #{pid} for resque-server that is probably not resque, so not killing it."
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
puts "Starting redis for testing at localhost:9736..."
|
metadata
CHANGED
@@ -1,143 +1,126 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-remora
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- nolan frausto
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
type: :runtime
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 27
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 10
|
31
|
-
version: "1.10"
|
32
|
-
version_requirements: *id001
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
33
14
|
name: resque
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :runtime
|
34
21
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 2
|
45
|
-
- 3
|
46
|
-
- 0
|
47
|
-
version: 2.3.0
|
48
|
-
version_requirements: *id002
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
49
28
|
name: rspec
|
50
|
-
|
51
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
52
34
|
type: :development
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 23
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 0
|
62
|
-
- 0
|
63
|
-
version: 1.0.0
|
64
|
-
version_requirements: *id003
|
65
|
-
name: bundler
|
66
35
|
prerelease: false
|
67
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
68
48
|
type: :development
|
69
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
|
-
requirements:
|
72
|
-
- - ~>
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
hash: 7
|
75
|
-
segments:
|
76
|
-
- 1
|
77
|
-
- 6
|
78
|
-
- 4
|
79
|
-
version: 1.6.4
|
80
|
-
version_requirements: *id004
|
81
|
-
name: jeweler
|
82
49
|
prerelease: false
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
88
59
|
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
|
92
|
-
- 0
|
93
|
-
version: "0"
|
94
|
-
version_requirements: *id005
|
95
|
-
name: rcov
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
96
63
|
prerelease: false
|
97
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
98
76
|
type: :development
|
99
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
|
-
requirements:
|
102
|
-
- - ~>
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
hash: 59
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
- 8
|
108
|
-
- 2
|
109
|
-
version: 0.8.2
|
110
|
-
version_requirements: *id006
|
111
|
-
name: yajl-ruby
|
112
77
|
prerelease: false
|
113
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yajl-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
114
90
|
type: :development
|
115
|
-
|
116
|
-
|
117
|
-
requirements:
|
118
|
-
- - ~>
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
|
121
|
-
|
122
|
-
- 1
|
123
|
-
- 5
|
124
|
-
- 3
|
125
|
-
version: 1.5.3
|
126
|
-
version_requirements: *id007
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
127
98
|
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.5.3
|
104
|
+
type: :development
|
128
105
|
prerelease: false
|
129
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.5.3
|
111
|
+
description: resque plugin that allows you to attach information when a job is put
|
112
|
+
in redis, and to do whatever you want with the information when it is popped off
|
113
|
+
the resque queue
|
130
114
|
email: nrfrausto@gmail.com
|
131
115
|
executables: []
|
132
|
-
|
133
116
|
extensions: []
|
134
|
-
|
135
|
-
extra_rdoc_files:
|
117
|
+
extra_rdoc_files:
|
136
118
|
- LICENSE.txt
|
137
119
|
- README.rdoc
|
138
|
-
files:
|
139
|
-
- .document
|
140
|
-
- .rspec
|
120
|
+
files:
|
121
|
+
- ".document"
|
122
|
+
- ".rspec"
|
123
|
+
- ".travis.yml"
|
141
124
|
- Gemfile
|
142
125
|
- LICENSE.txt
|
143
126
|
- README.rdoc
|
@@ -153,37 +136,28 @@ files:
|
|
153
136
|
- spec/spec_helper.rb
|
154
137
|
- spec/support/jobs.rb
|
155
138
|
homepage: http://github.com/frausto/resque-remora
|
156
|
-
licenses:
|
139
|
+
licenses:
|
157
140
|
- MIT
|
141
|
+
metadata: {}
|
158
142
|
post_install_message:
|
159
143
|
rdoc_options: []
|
160
|
-
|
161
|
-
require_paths:
|
144
|
+
require_paths:
|
162
145
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
requirements:
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
166
148
|
- - ">="
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
version: "0"
|
172
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
-
none: false
|
174
|
-
requirements:
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
175
153
|
- - ">="
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
version: "0"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
181
156
|
requirements: []
|
182
|
-
|
183
157
|
rubyforge_project:
|
184
|
-
rubygems_version:
|
158
|
+
rubygems_version: 2.7.6
|
185
159
|
signing_key:
|
186
|
-
specification_version:
|
187
|
-
summary: resque plugin that allows you to attach information to a resque job and retrieve
|
160
|
+
specification_version: 4
|
161
|
+
summary: resque plugin that allows you to attach information to a resque job and retrieve
|
162
|
+
it when it gets popped of the queue
|
188
163
|
test_files: []
|
189
|
-
|