resque-queue-status 0.1.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/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/resque/plugins/queue/status.rb +106 -0
- data/lib/resque/plugins/queue/status/version.rb +11 -0
- data/resque-queue-status.gemspec +31 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 15aaeda470d56fd3be4c882cebdc13202142e1249912d370cec777281570e5d2
|
4
|
+
data.tar.gz: 320b4f768f732aaceba36456178ae317ab31a037e9c5d761c0c0c1535fb7e0b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85b0dd1fc916c71297b486ff511073aceaf5ec94ce9448588cf3340e2c401c82ed10c92be673483e0384245bc1162a3f5bacf83c2b31c478a0640c79df56e5ab
|
7
|
+
data.tar.gz: 58bc568242adbc26f1f4c39e6db8d262795ef0b3606a1059305b641914e47d7279e837c46ef0bde441fa1001aa0ba90f7c0850aadbd9dd099a78180a496d2f6b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 ikuto
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Resque::Queue::Status
|
2
|
+
|
3
|
+
Resque Plugin adding simple queue statuses.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'resque-queue-status'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install resque-queue-status
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Extend Resque::Plugins::Queue::Status into your Resque Job.
|
24
|
+
You can specify your own key for your queues and check the status.
|
25
|
+
|
26
|
+
```
|
27
|
+
class ExampleJob
|
28
|
+
extend Resque::Plugins::Queue::Status
|
29
|
+
|
30
|
+
def self.perform()
|
31
|
+
puts 'hoge'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
Resque.enqueue(ExampleJob, queue_status_key: 'hoge')
|
37
|
+
ExampleJob.current_queue_status('hoge')
|
38
|
+
```
|
39
|
+
|
40
|
+
Statuses are `IN_PROGESS`, `COMPLETED` and `FAILED`.
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ikuto0608/resque-queue-status.
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "resque/queue/status"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'resque/plugins/queue/status/version'
|
5
|
+
|
6
|
+
module Resque
|
7
|
+
module Plugins
|
8
|
+
module Queue
|
9
|
+
# Resque::Plugins::Queue::Status.
|
10
|
+
# It provides adding simple queue statuses for your jobs.
|
11
|
+
# You can specify your own key for your queues and check the status.
|
12
|
+
#
|
13
|
+
# You can use it doing extend Resque::Plugins::Queue::Status
|
14
|
+
#
|
15
|
+
# For example
|
16
|
+
#
|
17
|
+
# class ExampleJob
|
18
|
+
# extend Resque::Plugins::Queue::Status
|
19
|
+
#
|
20
|
+
# def self.perform()
|
21
|
+
# puts 'hoge'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Resque.enqueue(ExampleJob, queue_status_key: 'hoge')
|
27
|
+
# ExampleJob.current_queue_status('hoge')
|
28
|
+
#
|
29
|
+
# The queue status key lasts 24 hours to expire
|
30
|
+
#
|
31
|
+
module Status
|
32
|
+
IN_PROGESS = 'IN_PROGESS'
|
33
|
+
COMPLETED = 'COMPLETED'
|
34
|
+
FAILED = 'FAILED'
|
35
|
+
STATUSES = [IN_PROGESS, COMPLETED, FAILED].freeze
|
36
|
+
|
37
|
+
def before_enqueue_queue_status(args)
|
38
|
+
_set_status(
|
39
|
+
queue_status_key: _queue_status_key(args),
|
40
|
+
status: IN_PROGESS
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def after_perform_queue_status(args)
|
45
|
+
_set_status(
|
46
|
+
queue_status_key: _queue_status_key(args),
|
47
|
+
status: COMPLETED
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def on_failure_queue_status(err, args)
|
52
|
+
_set_status(
|
53
|
+
queue_status_key: _queue_status_key(args),
|
54
|
+
status: FAILED,
|
55
|
+
meta: err.to_yaml
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_queue_status(queue_status_key)
|
60
|
+
JSON.parse(
|
61
|
+
Resque.redis.get(_namespaced_queue_status(queue_status_key)) || '{}',
|
62
|
+
symbolize_names: true
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def all_queue_statuses
|
67
|
+
Resque.redis.keys("#{_prefix}:*")
|
68
|
+
end
|
69
|
+
|
70
|
+
def clear_all_queue_statuses
|
71
|
+
Resque.redis.del(*all_queue_statuses) unless all_queue_statuses.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def _queue_status_key(args)
|
75
|
+
args['queue_status_key'] || args[:queue_status_key]
|
76
|
+
end
|
77
|
+
|
78
|
+
def _namespaced_queue_status(queue_status_key)
|
79
|
+
return if queue_status_key.nil?
|
80
|
+
|
81
|
+
queue_status_key_name = Resque::Job.decode(
|
82
|
+
Resque::Job.encode(queue_status_key)
|
83
|
+
)
|
84
|
+
"#{_prefix}:#{queue_status_key_name}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def _set_status(args)
|
88
|
+
queue_status = _namespaced_queue_status(args[:queue_status_key])
|
89
|
+
return if queue_status.nil?
|
90
|
+
|
91
|
+
Resque.redis.set(
|
92
|
+
queue_status,
|
93
|
+
args.slice(:status, :meta).to_json,
|
94
|
+
ex: 24 * 60 * 60
|
95
|
+
)
|
96
|
+
|
97
|
+
queue_status
|
98
|
+
end
|
99
|
+
|
100
|
+
def _prefix
|
101
|
+
"queuestatus:#{name}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "resque/plugins/queue/status/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "resque-queue-status"
|
8
|
+
spec.version = Resque::Plugins::Queue::Status::VERSION
|
9
|
+
spec.authors = ["ikuto"]
|
10
|
+
spec.email = ["ikuto0608@me.com"]
|
11
|
+
|
12
|
+
spec.summary = %q(Resque Plugin adding simple queue statuses.)
|
13
|
+
spec.description = %q(Resque Plugin adding simple queue statuses.)
|
14
|
+
spec.homepage = "http://github.com/ikuto0608/resque-queue-status"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "resque"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-queue-status
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ikuto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: resque
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Resque Plugin adding simple queue statuses.
|
70
|
+
email:
|
71
|
+
- ikuto0608@me.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/resque/plugins/queue/status.rb
|
86
|
+
- lib/resque/plugins/queue/status/version.rb
|
87
|
+
- resque-queue-status.gemspec
|
88
|
+
homepage: http://github.com/ikuto0608/resque-queue-status
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.0.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Resque Plugin adding simple queue statuses.
|
111
|
+
test_files: []
|