shinq 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 792190c7626e32ef84a9df82f9a0fb6502ae936a
4
- data.tar.gz: 5a9183334a17fe91af641bfc18d30f049b42edb3
3
+ metadata.gz: 01d64906303f1f93f1c58963b07d97b8d5f63ac7
4
+ data.tar.gz: 478a6b80464b1b399c19da69a8e37f4dc8dd7fbd
5
5
  SHA512:
6
- metadata.gz: 57bbdaa11b9f39ce503bb1f845c74cdae2cda448ebf8a3709200e5f7bc9b4bc7d128710a23e71ef6563a82d205158085ff949f3ceacfb795adfcea6c52035673
7
- data.tar.gz: '08b5390c1bc3aa2d38cfe3fafb5a9ceae784f8535a2a45bb1a6f3124ca8f1e33a57b3aa87f4250910695051a058457bbc94cd68784c22e6c79cd5174adb3d5a3'
6
+ metadata.gz: b165ea04629a8dd68d9e2ea480a27cdd663d69530562721cc726e8ce360a86d61188b031dde01c7da7fbd35d8a639cd2d63441f39e947563043206ff3c82a077
7
+ data.tar.gz: 7d8bef34453211d6e7e9bf6abc1ba19c881b7a42552dc76146d65d6e96bff947d090eeb68929e58c229a2998126fbb670a95adef3416f6e304f3aee5c5f20f5e
data/.travis.yml CHANGED
@@ -6,9 +6,11 @@ rvm:
6
6
  - 2.2.0
7
7
  - 2.2.1
8
8
  - 2.2.2
9
+ - 2.2.7
10
+ - 2.3.4
11
+ - 2.4.1
9
12
  gemfile:
10
13
  - Gemfile
11
14
  before_install:
12
15
  - mysql -e "create database IF NOT EXISTS shinq_test;" -uroot
13
- - mysql -e "use shinq_test; create table queue_test (job_id varchar(255) not null, title varchar(255), enqueued_at datetime not null);" -uroot
14
16
  script: bundle exec rspec
data/lib/shinq/cli.rb CHANGED
@@ -41,6 +41,10 @@ module Shinq
41
41
  opts[:process] = v.to_i
42
42
  end
43
43
 
44
+ opt.on('--graceful-kill-timeout VALUE', 'Seconds to SIGQUIT workers even during performing jobs') do |v|
45
+ opts[:graceful_kill_timeout] = v.to_i
46
+ end
47
+
44
48
  opt.on('--queue-timeout VALUE', 'Waiting queue time(sec). use function of queue_wait(Q4M)') do |v|
45
49
  opts[:queue_timeout] = v.to_i
46
50
  end
@@ -108,6 +112,7 @@ module Shinq
108
112
  worker_type: 'process',
109
113
  pid_file: 'shinq.pid',
110
114
  workers: options.process,
115
+ worker_graceful_kill_timeout: options.graceful_kill_timeout
111
116
  logger: options.daemonize ? Shinq.logger : nil
112
117
  })
113
118
 
@@ -10,11 +10,12 @@ module Shinq
10
10
  # You may need to set it +false+ for jobs which take very long time to proceed.
11
11
  # You may also need to handle performing error manually then.
12
12
  class Configuration
13
- attr_accessor :require, :worker_name, :worker_class, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize, :statistics, :lifecycle, :abort_on_error
13
+ attr_accessor :require, :worker_name, :worker_class, :db_config, :queue_db, :default_db, :process, :graceful_kill_timeout, :queue_timeout, :daemonize, :statistics, :lifecycle, :abort_on_error
14
14
 
15
15
  DEFAULT = {
16
16
  require: '.',
17
17
  process: 1,
18
+ graceful_kill_timeout: 600,
18
19
  queue_timeout: 1,
19
20
  daemonize: false,
20
21
  abort_on_error: true
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.1'
7
+ spec.version = '0.8.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.}
@@ -0,0 +1,6 @@
1
+ DROP TABLE IF EXISTS `queue_test`;
2
+ CREATE TABLE `queue_test` (
3
+ `job_id` varchar(255) NOT NULL,
4
+ `title` varchar(255),
5
+ `enqueued_at` datetime NOT NULL
6
+ ) ENGINE=QUEUE;
@@ -6,7 +6,10 @@ describe "Integration", skip: ENV['TRAVIS'] do
6
6
  let(:queue_table) { 'queue_test' }
7
7
 
8
8
  before do
9
- load_database_config(Shinq)
9
+ Shinq.configuration = {
10
+ default_db: :test,
11
+ db_config: load_database_config
12
+ }
10
13
  end
11
14
 
12
15
  after do
@@ -11,6 +11,7 @@ describe Shinq::Configuration do
11
11
  it { is_expected.to respond_to(:queue_db) }
12
12
  it { is_expected.to respond_to(:default_db) }
13
13
  it { is_expected.to respond_to(:process) }
14
+ it { is_expected.to respond_to(:graceful_kill_timeout) }
14
15
  it { is_expected.to respond_to(:queue_timeout) }
15
16
  it { is_expected.to respond_to(:daemonize) }
16
17
  it { is_expected.to respond_to(:statistics) }
data/spec/shinq_spec.rb CHANGED
@@ -61,7 +61,10 @@ describe Shinq do
61
61
  context "when db_config is not preset" do
62
62
  let(:shinq) {
63
63
  shinq_class.tap {|s|
64
- load_database_config(s)
64
+ s.configuration = {
65
+ db_config: load_database_config,
66
+ default_db: :test,
67
+ }
65
68
  }
66
69
  }
67
70
 
data/spec/spec_helper.rb CHANGED
@@ -3,9 +3,13 @@ require 'simplecov'
3
3
  require 'yaml'
4
4
  require 'active_support/core_ext/hash'
5
5
 
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ def load_database_config
7
+ db_config = YAML.load_file(File.expand_path('./config/database.yml', __dir__)).symbolize_keys
8
+ end
9
+
10
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
7
11
  SimpleCov::Formatter::HTMLFormatter
8
- ]
12
+ )
9
13
 
10
14
  SimpleCov.start do
11
15
  add_filter 'spec'
@@ -20,14 +24,11 @@ RSpec.configure do |config|
20
24
  config.default_formatter = 'doc'
21
25
  end
22
26
 
27
+ config.before(:suite) do
28
+ connection = Mysql2::Client.new(load_database_config[:test].merge(flags: Mysql2::Client::MULTI_STATEMENTS))
29
+ connection.query(File.read(File.expand_path('./db/structure.sql', __dir__)))
30
+ end
31
+
23
32
  config.order = :random
24
33
  Kernel.srand config.seed
25
34
  end
26
-
27
- def load_database_config(klass)
28
- db_config = YAML.load_file(File.expand_path('./config/database.yml', __dir__)).symbolize_keys
29
- klass.configuration = {
30
- db_config: db_config,
31
- default_db: :test
32
- }
33
- end
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.7.1
4
+ version: 0.8.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: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,6 +214,7 @@ files:
214
214
  - lib/shinq/statistics.rb
215
215
  - shinq.gemspec
216
216
  - spec/config/database.yml
217
+ - spec/db/structure.sql
217
218
  - spec/integration_spec.rb
218
219
  - spec/shinq/configuration_spec.rb
219
220
  - spec/shinq_spec.rb
@@ -244,6 +245,7 @@ specification_version: 4
244
245
  summary: Worker and enqueuer for Q4M using the interface of ActiveJob.
245
246
  test_files:
246
247
  - spec/config/database.yml
248
+ - spec/db/structure.sql
247
249
  - spec/integration_spec.rb
248
250
  - spec/shinq/configuration_spec.rb
249
251
  - spec/shinq_spec.rb