shinq 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 +4 -4
- data/lib/shinq/cli.rb +12 -5
- data/lib/shinq/configuration.rb +2 -2
- data/lib/shinq/statistics.rb +17 -0
- data/shinq.gemspec +1 -1
- data/spec/shinq/configuration_spec.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c2780c72c0818659e65f0cf005dcd19d78cb3cb
|
4
|
+
data.tar.gz: 48fc9366fb03e2efc32df1d865e9358a920db6ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51fc1856fd6ced06b6f54c483cd6235dd9d095cb9de3359c278f1776ec0c0d7dd106b2fa1acd8c0a9ee095b941dfb35fdb5675459a2122823265a3d6e3420139
|
7
|
+
data.tar.gz: d8b4bc498f2db51975cde120f6e8ae5815fce0365c86bad579dbb6ccf342d4f30ad8760fc431649cafb59f71b606db7c827530c7d0f284db1d39768bc64e4c6e
|
data/lib/shinq/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'optparse'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'shinq'
|
4
4
|
require 'shinq/launcher'
|
5
|
+
require 'shinq/statistics'
|
5
6
|
require 'shinq/configuration'
|
6
7
|
require 'serverengine'
|
7
8
|
|
@@ -27,11 +28,11 @@ module Shinq
|
|
27
28
|
opts[:daemonize] = v
|
28
29
|
end
|
29
30
|
|
30
|
-
opt.on('--worker value', 'Name of worker class') do |v|
|
31
|
+
opt.on('-w', '--worker value', 'Name of worker class') do |v|
|
31
32
|
opts[:worker_name] = v
|
32
33
|
end
|
33
34
|
|
34
|
-
opt.on('--process VALUE', 'Number of workers') do |v|
|
35
|
+
opt.on('-p', '--process VALUE', 'Number of workers') do |v|
|
35
36
|
opts[:process] = v.to_i
|
36
37
|
end
|
37
38
|
|
@@ -39,7 +40,7 @@ module Shinq
|
|
39
40
|
opts[:queue_timeout] = v.to_i
|
40
41
|
end
|
41
42
|
|
42
|
-
opt.on('--db-config VALUE', 'Specify configuration file') do |v|
|
43
|
+
opt.on('--db-config VALUE', 'Specify database configuration file') do |v|
|
43
44
|
raise OptionParseError, "#{v} does not exist" unless File.exist?(v)
|
44
45
|
opts[:db_config] = YAML.load_file(v)
|
45
46
|
end
|
@@ -49,10 +50,14 @@ module Shinq
|
|
49
50
|
opts[:queue_db] = v
|
50
51
|
end
|
51
52
|
|
52
|
-
opt.on('--require VALUE', 'Add require path') do |v|
|
53
|
+
opt.on('-r', '--require VALUE', 'Add require path') do |v|
|
53
54
|
opts[:require] = v
|
54
55
|
end
|
55
56
|
|
57
|
+
opt.on('-s', '--statistics VALUE', 'Display queue statistics interval time(sec)') do |v|
|
58
|
+
opts[:statistics] = v.to_i
|
59
|
+
end
|
60
|
+
|
56
61
|
opt.on('-v', '--version', 'Print version') do |v|
|
57
62
|
puts "Shinq #{Shinq::VERSION}"
|
58
63
|
exit(0)
|
@@ -82,7 +87,9 @@ module Shinq
|
|
82
87
|
end
|
83
88
|
|
84
89
|
def run
|
85
|
-
|
90
|
+
klass = !options.statistics.nil? && options.statistics ? Shinq::Statistics : Shinq::Launcher
|
91
|
+
|
92
|
+
se = ServerEngine.create(nil, klass, {
|
86
93
|
daemonize: options.daemonize,
|
87
94
|
worker_type: 'process',
|
88
95
|
pid_file: 'shinq.pid',
|
data/lib/shinq/configuration.rb
CHANGED
@@ -2,7 +2,7 @@ module Shinq
|
|
2
2
|
class ConfigurationError < StandardError; end
|
3
3
|
|
4
4
|
class Configuration
|
5
|
-
attr_accessor :require, :worker_name, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize
|
5
|
+
attr_accessor :require, :worker_name, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize, :statistics
|
6
6
|
|
7
7
|
DEFAULT = {
|
8
8
|
require: '.',
|
@@ -12,7 +12,7 @@ module Shinq
|
|
12
12
|
}
|
13
13
|
|
14
14
|
def initialize(opts)
|
15
|
-
%i(require worker_name db_config queue_db default_db process queue_timeout daemonize).each do |k|
|
15
|
+
%i(require worker_name db_config queue_db default_db process queue_timeout daemonize statistics).each do |k|
|
16
16
|
send(:"#{k}=", opts[k] || DEFAULT[k])
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'shinq/client'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
|
4
|
+
module Shinq
|
5
|
+
module Statistics
|
6
|
+
def run
|
7
|
+
until @stop
|
8
|
+
p Shinq::Client.queue_stats(table_name: Shinq.configuration.worker_name.pluralize)
|
9
|
+
sleep Shinq.configuration.statistics
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def stop
|
14
|
+
@stop = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/shinq.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "shinq"
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.3.0'
|
8
8
|
spec.authors = ["Ryoichi SEKIGUCHI"]
|
9
9
|
spec.email = ["ryopeko@gmail.com"]
|
10
10
|
spec.summary = %q{Worker and enqueuer for Q4M using the interface of ActiveJob.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shinq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryoichi SEKIGUCHI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/shinq/configuration.rb
|
191
191
|
- lib/shinq/launcher.rb
|
192
192
|
- lib/shinq/rails.rb
|
193
|
+
- lib/shinq/statistics.rb
|
193
194
|
- shinq.gemspec
|
194
195
|
- spec/config/database.yml
|
195
196
|
- spec/integration_spec.rb
|