shinq 1.3.0 → 1.4.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/.github/workflows/test.yml +29 -23
 - data/.gitignore +1 -0
 - data/Appraisals +18 -12
 - data/README.md +3 -2
 - data/gemfiles/rails_7.0.gemfile +1 -0
 - data/gemfiles/{rails_5.gemfile → rails_7.1.gemfile} +2 -2
 - data/gemfiles/{rails_6.0.gemfile → rails_7.2.gemfile} +2 -2
 - data/gemfiles/{rails_6.1.gemfile → rails_8.0.gemfile} +2 -2
 - data/gemfiles/rails_8.1.gemfile +8 -0
 - data/lib/shinq/client.rb +4 -4
 - data/lib/shinq.rb +14 -3
 - data/shinq.gemspec +5 -4
 - data/spec/integration_spec.rb +3 -3
 - data/spec/shinq/client_spec.rb +2 -2
 - data/spec/shinq_spec.rb +19 -2
 - data/spec/spec_helper.rb +2 -2
 - metadata +24 -31
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4500852828c16cc3dc647eb066a1b6ebf1851783b916bb76a4afd2e220bc9382
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 943f21748666dfd25f14fcde22abe7266bd39ef989facd673c0246e38be78611
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: dd06574c63da919a33f03a5242584fead594e4030584dfe6b95100911fbcfcaaed55ac25fb2a2433360f8de10bb7086ef1620286aa48db61c99adbf5e32aa3b7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 85e7f4354633f56bdc6357d8e8afd0cfbb27b1dd6a85e2784d9476a63eb4ca029cd2a08c64596100096bb5c81e1cb48b0ac7c39b3cc1288a60d277e1db35e2bc
         
     | 
    
        data/.github/workflows/test.yml
    CHANGED
    
    | 
         @@ -18,42 +18,46 @@ on: 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            jobs:
         
     | 
| 
       20 
20 
     | 
    
         
             
              test:
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
21 
     | 
    
         
             
                runs-on: ubuntu-latest
         
     | 
| 
       23 
     | 
    
         
            -
                
         
     | 
| 
       24 
22 
     | 
    
         
             
                strategy:
         
     | 
| 
       25 
23 
     | 
    
         
             
                  max-parallel: 4
         
     | 
| 
       26 
24 
     | 
    
         
             
                  fail-fast: true
         
     | 
| 
       27 
25 
     | 
    
         
             
                  matrix:
         
     | 
| 
       28 
     | 
    
         
            -
                    # In order to effectively specify Rails and Ruby versions simultaneously,
         
     | 
| 
       29 
     | 
    
         
            -
                    # we specify every tuple of versions in `include` section
         
     | 
| 
       30 
     | 
    
         
            -
                    # except for the tuples with a particular Rails version.
         
     | 
| 
       31 
     | 
    
         
            -
                    #
         
     | 
| 
       32 
     | 
    
         
            -
                    # The objective of the exception is to satisfy the
         
     | 
| 
       33 
     | 
    
         
            -
                    # constraint that a matrix cannot be empty.
         
     | 
| 
       34 
     | 
    
         
            -
                    #
         
     | 
| 
       35 
26 
     | 
    
         
             
                    # We test only the oldest and latest Ruby versions for each Rails version.
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
                    ruby: ['2.3', '2.6']
         
     | 
| 
       38 
     | 
    
         
            -
                    include:
         
     | 
| 
       39 
     | 
    
         
            -
                      - gemfile: gemfiles/rails_6.0.gemfile
         
     | 
| 
       40 
     | 
    
         
            -
                        ruby: '2.5'
         
     | 
| 
       41 
     | 
    
         
            -
                      - gemfile: gemfiles/rails_6.0.gemfile
         
     | 
| 
       42 
     | 
    
         
            -
                        ruby: '2.7'
         
     | 
| 
       43 
     | 
    
         
            -
                      - gemfile: gemfiles/rails_6.1.gemfile
         
     | 
| 
       44 
     | 
    
         
            -
                        ruby: '2.5'
         
     | 
| 
       45 
     | 
    
         
            -
                      - gemfile: gemfiles/rails_6.1.gemfile
         
     | 
| 
       46 
     | 
    
         
            -
                        ruby: '3.2'
         
     | 
| 
      
 27 
     | 
    
         
            +
                    ruby_gemfile:
         
     | 
| 
       47 
28 
     | 
    
         
             
                      - gemfile: gemfiles/rails_7.0.gemfile
         
     | 
| 
       48 
29 
     | 
    
         
             
                        ruby: '2.7'
         
     | 
| 
       49 
30 
     | 
    
         
             
                      - gemfile: gemfiles/rails_7.0.gemfile
         
     | 
| 
      
 31 
     | 
    
         
            +
                        ruby: '3.3'
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_7.1.gemfile
         
     | 
| 
      
 34 
     | 
    
         
            +
                        ruby: '2.7'
         
     | 
| 
      
 35 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_7.1.gemfile
         
     | 
| 
      
 36 
     | 
    
         
            +
                        ruby: '3.4'
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_7.2.gemfile
         
     | 
| 
      
 39 
     | 
    
         
            +
                        ruby: '3.1'
         
     | 
| 
      
 40 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_7.2.gemfile
         
     | 
| 
      
 41 
     | 
    
         
            +
                        ruby: '3.4'
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_8.0.gemfile
         
     | 
| 
       50 
44 
     | 
    
         
             
                        ruby: '3.2'
         
     | 
| 
      
 45 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_8.0.gemfile
         
     | 
| 
      
 46 
     | 
    
         
            +
                        ruby: '3.4'
         
     | 
| 
       51 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_8.1.gemfile
         
     | 
| 
      
 49 
     | 
    
         
            +
                        ruby: '3.2'
         
     | 
| 
      
 50 
     | 
    
         
            +
                      - gemfile: gemfiles/rails_8.1.gemfile
         
     | 
| 
      
 51 
     | 
    
         
            +
                        ruby: '3.4'
         
     | 
| 
      
 52 
     | 
    
         
            +
                    adapter:
         
     | 
| 
      
 53 
     | 
    
         
            +
                      - trilogy
         
     | 
| 
      
 54 
     | 
    
         
            +
                      - mysql2
         
     | 
| 
       52 
55 
     | 
    
         
             
                env:
         
     | 
| 
       53 
     | 
    
         
            -
                  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
         
     | 
| 
      
 56 
     | 
    
         
            +
                  BUNDLE_GEMFILE: ${{ matrix.ruby_gemfile.gemfile }}
         
     | 
| 
       54 
57 
     | 
    
         
             
                services:
         
     | 
| 
       55 
58 
     | 
    
         
             
                  mysql:
         
     | 
| 
       56 
     | 
    
         
            -
                     
     | 
| 
      
 59 
     | 
    
         
            +
                    # https://github.com/DeNA/ubuntu22-mysql-q4m
         
     | 
| 
      
 60 
     | 
    
         
            +
                    image: ghcr.io/dena/ubuntu22-mysql-q4m:8.0.28-6bc571978335b6304566c8df4a5ff7e2b2d9911f
         
     | 
| 
       57 
61 
     | 
    
         
             
                    ports:
         
     | 
| 
       58 
62 
     | 
    
         
             
                      - 3306:3306
         
     | 
| 
       59 
63 
     | 
    
         
             
                steps:
         
     | 
| 
         @@ -65,8 +69,10 @@ jobs: 
     | 
|
| 
       65 
69 
     | 
    
         
             
                  uses: ruby/setup-ruby@v1
         
     | 
| 
       66 
70 
     | 
    
         
             
                  with:
         
     | 
| 
       67 
71 
     | 
    
         
             
                    bundler-cache: true
         
     | 
| 
       68 
     | 
    
         
            -
                    ruby-version: ${{ matrix.ruby }}
         
     | 
| 
      
 72 
     | 
    
         
            +
                    ruby-version: ${{ matrix.ruby_gemfile.ruby }}
         
     | 
| 
       69 
73 
     | 
    
         
             
                - name: Install dependencies
         
     | 
| 
       70 
74 
     | 
    
         
             
                  run: bundle install
         
     | 
| 
       71 
75 
     | 
    
         
             
                - name: Run tests
         
     | 
| 
      
 76 
     | 
    
         
            +
                  env:
         
     | 
| 
      
 77 
     | 
    
         
            +
                    SHINQ_TEST_ADAPTER: ${{ matrix.adapter }}
         
     | 
| 
       72 
78 
     | 
    
         
             
                  run: bundle exec rspec
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/Appraisals
    CHANGED
    
    | 
         @@ -10,22 +10,28 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            #   gem "rails", "~> 4.0"
         
     | 
| 
       11 
11 
     | 
    
         
             
            # end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            appraise "rails- 
     | 
| 
       14 
     | 
    
         
            -
              gem "activesupport", "~>  
     | 
| 
       15 
     | 
    
         
            -
              gem "activejob", "~>  
     | 
| 
      
 13 
     | 
    
         
            +
            appraise "rails-7.0" do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem "activesupport", "~> 7.0.0"
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem "activejob", "~> 7.0.0"
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem 'concurrent-ruby', '1.3.4' # https://stackoverflow.com/a/79361034
         
     | 
| 
       16 
17 
     | 
    
         
             
            end
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            appraise "rails- 
     | 
| 
       19 
     | 
    
         
            -
              gem "activesupport", "~>  
     | 
| 
       20 
     | 
    
         
            -
              gem "activejob", "~>  
     | 
| 
      
 19 
     | 
    
         
            +
            appraise "rails-7.1" do
         
     | 
| 
      
 20 
     | 
    
         
            +
              gem "activesupport", "~> 7.1.0"
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem "activejob", "~> 7.1.0"
         
     | 
| 
       21 
22 
     | 
    
         
             
            end
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            appraise "rails- 
     | 
| 
       24 
     | 
    
         
            -
              gem "activesupport", "~>  
     | 
| 
       25 
     | 
    
         
            -
              gem "activejob", "~>  
     | 
| 
      
 24 
     | 
    
         
            +
            appraise "rails-7.2" do
         
     | 
| 
      
 25 
     | 
    
         
            +
              gem "activesupport", "~> 7.2.0"
         
     | 
| 
      
 26 
     | 
    
         
            +
              gem "activejob", "~> 7.2.0"
         
     | 
| 
       26 
27 
     | 
    
         
             
            end
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
            appraise "rails- 
     | 
| 
       29 
     | 
    
         
            -
              gem "activesupport", "~>  
     | 
| 
       30 
     | 
    
         
            -
              gem "activejob", "~>  
     | 
| 
      
 29 
     | 
    
         
            +
            appraise "rails-8.0" do
         
     | 
| 
      
 30 
     | 
    
         
            +
              gem "activesupport", "~> 8.0.0"
         
     | 
| 
      
 31 
     | 
    
         
            +
              gem "activejob", "~> 8.0.0"
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            appraise "rails-8.1" do
         
     | 
| 
      
 35 
     | 
    
         
            +
              gem "activesupport", "~> 8.1.0"
         
     | 
| 
      
 36 
     | 
    
         
            +
              gem "activejob", "~> 8.1.0"
         
     | 
| 
       31 
37 
     | 
    
         
             
            end
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -6,9 +6,10 @@ Worker and enqueuer for Q4M using the interface of ActiveJob. 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            ## Installation
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            Add  
     | 
| 
      
 9 
     | 
    
         
            +
            Add these lines to your application's Gemfile:
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            ```ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'mysql2' # or gem 'trilogy'
         
     | 
| 
       12 
13 
     | 
    
         
             
            gem 'shinq'
         
     | 
| 
       13 
14 
     | 
    
         
             
            ```
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
         @@ -18,7 +19,7 @@ And then execute: 
     | 
|
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
            Or install it yourself as:
         
     | 
| 
       20 
21 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                $ gem install shinq
         
     | 
| 
      
 22 
     | 
    
         
            +
                $ gem install mysql2 shinq
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
            [Install Q4M](http://q4m.github.io/install.html)
         
     | 
| 
       24 
25 
     | 
    
         | 
    
        data/gemfiles/rails_7.0.gemfile
    CHANGED
    
    
    
        data/lib/shinq/client.rb
    CHANGED
    
    | 
         @@ -36,11 +36,11 @@ module Shinq 
     | 
|
| 
       36 
36 
     | 
    
         
             
                  wait_query = "queue_wait(#{quoted}, #{queue_timeout_quoted})"
         
     | 
| 
       37 
37 
     | 
    
         
             
                  has_queue = Shinq.connection.query("select #{wait_query}").first
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                  unless has_queue[ 
     | 
| 
      
 39 
     | 
    
         
            +
                  unless has_queue[0].to_i == 0
         
     | 
| 
       40 
40 
     | 
    
         
             
                    sql = builder.select(table_name, ['*'])
         
     | 
| 
       41 
41 
     | 
    
         
             
                    results = Shinq.connection.query(sql)
         
     | 
| 
       42 
42 
     | 
    
         
             
                    # select always returns 1 line in the owner (queue_wait) mode
         
     | 
| 
       43 
     | 
    
         
            -
                    return results.first. 
     | 
| 
      
 43 
     | 
    
         
            +
                    return results.fields.map(&:to_sym).zip(results.each.first).to_h
         
     | 
| 
       44 
44 
     | 
    
         
             
                  end
         
     | 
| 
       45 
45 
     | 
    
         
             
                end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
         @@ -50,7 +50,7 @@ module Shinq 
     | 
|
| 
       50 
50 
     | 
    
         
             
                  stats_query = "queue_stats(#{quoted})"
         
     | 
| 
       51 
51 
     | 
    
         
             
                  result = Shinq.connection.query("select #{stats_query}")
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                  stats = result.first[ 
     | 
| 
      
 53 
     | 
    
         
            +
                  stats = result.first[0].split(/\n/).each_with_object({}) do |s, h|
         
     | 
| 
       54 
54 
     | 
    
         
             
                    (k,v) = s.split(/:/)
         
     | 
| 
       55 
55 
     | 
    
         
             
                    h[k.to_sym] = v.to_i
         
     | 
| 
       56 
56 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -68,7 +68,7 @@ module Shinq 
     | 
|
| 
       68 
68 
     | 
    
         
             
                  @column_names_by_table_name ||= {}
         
     | 
| 
       69 
69 
     | 
    
         
             
                  @column_names_by_table_name[table_name.to_sym] ||= begin
         
     | 
| 
       70 
70 
     | 
    
         
             
                    quoted = SQL::Maker::Quoting.quote(table_name)
         
     | 
| 
       71 
     | 
    
         
            -
                    column = Shinq.connection.query(<<-EOS).map { |record| record[ 
     | 
| 
      
 71 
     | 
    
         
            +
                    column = Shinq.connection.query(<<-EOS).map { |record| record[0] }
         
     | 
| 
       72 
72 
     | 
    
         
             
            select column_name as column_name from information_schema.columns where table_schema = database() and table_name = #{quoted}
         
     | 
| 
       73 
73 
     | 
    
         
             
                    EOS
         
     | 
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/shinq.rb
    CHANGED
    
    | 
         @@ -1,4 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'mysql2'
         
     | 
| 
       2 
1 
     | 
    
         
             
            require 'shinq/client'
         
     | 
| 
       3 
2 
     | 
    
         
             
            require 'shinq/configuration'
         
     | 
| 
       4 
3 
     | 
    
         | 
| 
         @@ -23,8 +22,20 @@ module Shinq 
     | 
|
| 
       23 
22 
     | 
    
         
             
              end
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
24 
     | 
    
         
             
              def self.setup_db_connection(db_name)
         
     | 
| 
       26 
     | 
    
         
            -
                raise Shinq::ConfigurationError unless self.configuration.db_defined?(db_name)
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                raise Shinq::ConfigurationError, "#{db_name.inspect} is not defined in configuration" unless self.configuration.db_defined?(db_name)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                db_config = self.configuration.db_config[db_name]
         
     | 
| 
      
 28 
     | 
    
         
            +
                @connections[db_name.to_sym] =
         
     | 
| 
      
 29 
     | 
    
         
            +
                  case db_config[:adapter]
         
     | 
| 
      
 30 
     | 
    
         
            +
                  when 'trilogy'
         
     | 
| 
      
 31 
     | 
    
         
            +
                    require 'trilogy'
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Trilogy.new(db_config.dup)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  when 'mysql2', nil # for backward compatibility, we use mysql2 when adapter is not specified
         
     | 
| 
      
 34 
     | 
    
         
            +
                    require 'mysql2'
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Mysql2::Client.new(db_config.merge(as: :array))
         
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
                    raise "Unsupported adapter: #{db_config[:adapter]}. Only trilogy and mysql2 are supported."
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
       28 
39 
     | 
    
         
             
              end
         
     | 
| 
       29 
40 
     | 
    
         | 
| 
       30 
41 
     | 
    
         
             
              def self.connection(db_name: self.default_db)
         
     | 
    
        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       = '1. 
     | 
| 
      
 7 
     | 
    
         
            +
              spec.version       = '1.4.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.}
         
     | 
| 
         @@ -26,11 +26,12 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       26 
26 
     | 
    
         
             
              spec.add_development_dependency "simplecov"
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.add_development_dependency "timecop"
         
     | 
| 
       28 
28 
     | 
    
         
             
              spec.add_development_dependency "appraisal"
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.add_development_dependency "trilogy"
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_development_dependency "mysql2"
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
              spec.add_dependency "mysql2", ">= 0.3.16", "< 1"
         
     | 
| 
       31 
32 
     | 
    
         
             
              spec.add_dependency "sql-maker", ">= 0.0.4", "< 2"
         
     | 
| 
       32 
33 
     | 
    
         
             
              spec.add_dependency 'serverengine', ">= 1.5.9", "< 3"
         
     | 
| 
       33 
34 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              spec.add_dependency "activesupport", ">= 4.2.0" 
     | 
| 
       35 
     | 
    
         
            -
              spec.add_dependency "activejob", ">= 4.2.0" 
     | 
| 
      
 35 
     | 
    
         
            +
              spec.add_dependency "activesupport", ">= 4.2.0"
         
     | 
| 
      
 36 
     | 
    
         
            +
              spec.add_dependency "activejob", ">= 4.2.0"
         
     | 
| 
       36 
37 
     | 
    
         
             
            end
         
     | 
    
        data/spec/integration_spec.rb
    CHANGED
    
    | 
         @@ -14,7 +14,7 @@ describe "Integration" do 
     | 
|
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              after do
         
     | 
| 
       16 
16 
     | 
    
         
             
                Shinq.clear_all_connections! # Return from owner mode
         
     | 
| 
       17 
     | 
    
         
            -
                tables = Shinq.connection.query('show tables'). 
     | 
| 
      
 17 
     | 
    
         
            +
                tables = Shinq.connection.query('show tables').to_a.flatten
         
     | 
| 
       18 
18 
     | 
    
         
             
                tables.each do |table|
         
     | 
| 
       19 
19 
     | 
    
         
             
                  Shinq.connection.query("delete from #{table}")
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
         @@ -127,12 +127,12 @@ describe "Integration" do 
     | 
|
| 
       127 
127 
     | 
    
         
             
                      args: {title: 'foo'}
         
     | 
| 
       128 
128 
     | 
    
         
             
                    )
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                    @queue_count = Shinq.connection.query("select count(*) as c from #{queue_table}").first 
     | 
| 
      
 130 
     | 
    
         
            +
                    @queue_count = Shinq.connection.query("select count(*) as c from #{queue_table}").first.first
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
                    Shinq::Client.dequeue(table_name: queue_table)
         
     | 
| 
       133 
133 
     | 
    
         
             
                    Shinq::Client.abort
         
     | 
| 
       134 
134 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
                    @after_queue_count = Shinq.connection.query("select count(*) as c from #{queue_table}").first 
     | 
| 
      
 135 
     | 
    
         
            +
                    @after_queue_count = Shinq.connection.query("select count(*) as c from #{queue_table}").first.first
         
     | 
| 
       136 
136 
     | 
    
         
             
                  end
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
138 
     | 
    
         
             
                  it { expect(@after_queue_count).to be @queue_count }
         
     | 
    
        data/spec/shinq/client_spec.rb
    CHANGED
    
    | 
         @@ -34,13 +34,13 @@ describe Shinq::Client do 
     | 
|
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
              describe '.column_names' do
         
     | 
| 
       36 
36 
     | 
    
         
             
                it 'fetches column_names' do
         
     | 
| 
       37 
     | 
    
         
            -
                  expect(shinq_client.column_names(table_name: :queue_test)).to eq(['job_id', 'title', 'scheduled_at', 'enqueued_at'])
         
     | 
| 
      
 37 
     | 
    
         
            +
                  expect(shinq_client.column_names(table_name: :queue_test).sort).to eq(['job_id', 'title', 'scheduled_at', 'enqueued_at'].sort)
         
     | 
| 
       38 
38 
     | 
    
         
             
                end
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
              describe 'fetch_column_names' do
         
     | 
| 
       42 
42 
     | 
    
         
             
                it 'fetches column_names' do
         
     | 
| 
       43 
     | 
    
         
            -
                  expect(shinq_client.fetch_column_names(table_name: :queue_test)).to eq(['job_id', 'title', 'scheduled_at', 'enqueued_at'])
         
     | 
| 
      
 43 
     | 
    
         
            +
                  expect(shinq_client.fetch_column_names(table_name: :queue_test).sort).to eq(['job_id', 'title', 'scheduled_at', 'enqueued_at'].sort)
         
     | 
| 
       44 
44 
     | 
    
         
             
                end
         
     | 
| 
       45 
45 
     | 
    
         
             
              end
         
     | 
| 
       46 
46 
     | 
    
         
             
            end
         
     | 
    
        data/spec/shinq_spec.rb
    CHANGED
    
    | 
         @@ -64,7 +64,14 @@ describe Shinq do 
     | 
|
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                  it do
         
     | 
| 
       66 
66 
     | 
    
         
             
                    shinq.connection(db_name: :test)
         
     | 
| 
       67 
     | 
    
         
            -
                     
     | 
| 
      
 67 
     | 
    
         
            +
                    case shinq.configuration.default_db_config[:adapter]
         
     | 
| 
      
 68 
     | 
    
         
            +
                    when 'mysql2'
         
     | 
| 
      
 69 
     | 
    
         
            +
                      expect(shinq.connection(db_name: :test)).to be_a_kind_of(Mysql2::Client)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    when 'trilogy'
         
     | 
| 
      
 71 
     | 
    
         
            +
                      expect(shinq.connection(db_name: :test)).to be_a_kind_of(Trilogy)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    else
         
     | 
| 
      
 73 
     | 
    
         
            +
                      raise "Unexpected adapter: #{shinq.configuration.default_db_config[:adapter]}"
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end
         
     | 
| 
       68 
75 
     | 
    
         
             
                  end
         
     | 
| 
       69 
76 
     | 
    
         
             
                end
         
     | 
| 
       70 
77 
     | 
    
         
             
              end
         
     | 
| 
         @@ -83,7 +90,17 @@ describe Shinq do 
     | 
|
| 
       83 
90 
     | 
    
         | 
| 
       84 
91 
     | 
    
         
             
                  it 'closes connection' do
         
     | 
| 
       85 
92 
     | 
    
         
             
                    shinq.clear_all_connections!
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                    # Trilogy raises an exception while mysql2 returns false
         
     | 
| 
      
 95 
     | 
    
         
            +
                    # see: https://github.com/trilogy-libraries/trilogy/pull/145
         
     | 
| 
      
 96 
     | 
    
         
            +
                    case shinq.configuration.default_db_config[:adapter]
         
     | 
| 
      
 97 
     | 
    
         
            +
                    when 'trilogy'
         
     | 
| 
      
 98 
     | 
    
         
            +
                      expect { connection.ping }.to raise_error Trilogy::ConnectionClosed
         
     | 
| 
      
 99 
     | 
    
         
            +
                    when 'mysql2'
         
     | 
| 
      
 100 
     | 
    
         
            +
                      expect(connection.ping).to eq false
         
     | 
| 
      
 101 
     | 
    
         
            +
                    else
         
     | 
| 
      
 102 
     | 
    
         
            +
                      raise "Unexpected adapter: #{shinq.configuration.default_db_config[:adapter]}"
         
     | 
| 
      
 103 
     | 
    
         
            +
                    end
         
     | 
| 
       87 
104 
     | 
    
         
             
                  end
         
     | 
| 
       88 
105 
     | 
    
         | 
| 
       89 
106 
     | 
    
         
             
                  it 'clears connection cache' do
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -11,8 +11,8 @@ require 'active_support/core_ext/numeric/time' 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require 'mysql2'
         
     | 
| 
       12 
12 
     | 
    
         
             
            require 'timecop'
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            def load_database_config
         
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
      
 14 
     | 
    
         
            +
            def load_database_config(adapter: ENV.fetch('SHINQ_TEST_ADAPTER', 'trilogy'))
         
     | 
| 
      
 15 
     | 
    
         
            +
              YAML.load_file(File.expand_path('./config/database.yml', __dir__)).deep_symbolize_keys.deep_merge(test: { adapter: adapter })
         
     | 
| 
       16 
16 
     | 
    
         
             
            end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
            SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: shinq
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ryoichi SEKIGUCHI
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
         
     | 
| 
       9 
8 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
9 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 10 
     | 
    
         
            +
            date: 2025-11-04 00:00:00.000000000 Z
         
     | 
| 
       12 
11 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
12 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
13 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -123,25 +122,33 @@ dependencies: 
     | 
|
| 
       123 
122 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       124 
123 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       125 
124 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       126 
     | 
    
         
            -
              name:  
     | 
| 
      
 125 
     | 
    
         
            +
              name: trilogy
         
     | 
| 
       127 
126 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       128 
127 
     | 
    
         
             
                requirements:
         
     | 
| 
       129 
128 
     | 
    
         
             
                - - ">="
         
     | 
| 
       130 
129 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       131 
     | 
    
         
            -
                    version: 0 
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       134 
     | 
    
         
            -
                    version: '1'
         
     | 
| 
       135 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
      
 130 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 131 
     | 
    
         
            +
              type: :development
         
     | 
| 
       136 
132 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       137 
133 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       138 
134 
     | 
    
         
             
                requirements:
         
     | 
| 
       139 
135 
     | 
    
         
             
                - - ">="
         
     | 
| 
       140 
136 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       141 
     | 
    
         
            -
                    version: 0 
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
      
 137 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 138 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 139 
     | 
    
         
            +
              name: mysql2
         
     | 
| 
      
 140 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 141 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 142 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       143 
143 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       144 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 144 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 145 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 146 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 147 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 148 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 149 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 150 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 151 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       145 
152 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       146 
153 
     | 
    
         
             
              name: sql-maker
         
     | 
| 
       147 
154 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -189,9 +196,6 @@ dependencies: 
     | 
|
| 
       189 
196 
     | 
    
         
             
                - - ">="
         
     | 
| 
       190 
197 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       191 
198 
     | 
    
         
             
                    version: 4.2.0
         
     | 
| 
       192 
     | 
    
         
            -
                - - "<"
         
     | 
| 
       193 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       194 
     | 
    
         
            -
                    version: '7.1'
         
     | 
| 
       195 
199 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       196 
200 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       197 
201 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -199,9 +203,6 @@ dependencies: 
     | 
|
| 
       199 
203 
     | 
    
         
             
                - - ">="
         
     | 
| 
       200 
204 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       201 
205 
     | 
    
         
             
                    version: 4.2.0
         
     | 
| 
       202 
     | 
    
         
            -
                - - "<"
         
     | 
| 
       203 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       204 
     | 
    
         
            -
                    version: '7.1'
         
     | 
| 
       205 
206 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       206 
207 
     | 
    
         
             
              name: activejob
         
     | 
| 
       207 
208 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -209,9 +210,6 @@ dependencies: 
     | 
|
| 
       209 
210 
     | 
    
         
             
                - - ">="
         
     | 
| 
       210 
211 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       211 
212 
     | 
    
         
             
                    version: 4.2.0
         
     | 
| 
       212 
     | 
    
         
            -
                - - "<"
         
     | 
| 
       213 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       214 
     | 
    
         
            -
                    version: '7.1'
         
     | 
| 
       215 
213 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       216 
214 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       217 
215 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -219,10 +217,6 @@ dependencies: 
     | 
|
| 
       219 
217 
     | 
    
         
             
                - - ">="
         
     | 
| 
       220 
218 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       221 
219 
     | 
    
         
             
                    version: 4.2.0
         
     | 
| 
       222 
     | 
    
         
            -
                - - "<"
         
     | 
| 
       223 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       224 
     | 
    
         
            -
                    version: '7.1'
         
     | 
| 
       225 
     | 
    
         
            -
            description: 
         
     | 
| 
       226 
220 
     | 
    
         
             
            email:
         
     | 
| 
       227 
221 
     | 
    
         
             
            - ryopeko@gmail.com
         
     | 
| 
       228 
222 
     | 
    
         
             
            executables:
         
     | 
| 
         @@ -239,10 +233,11 @@ files: 
     | 
|
| 
       239 
233 
     | 
    
         
             
            - README.md
         
     | 
| 
       240 
234 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       241 
235 
     | 
    
         
             
            - bin/shinq
         
     | 
| 
       242 
     | 
    
         
            -
            - gemfiles/rails_5.gemfile
         
     | 
| 
       243 
     | 
    
         
            -
            - gemfiles/rails_6.0.gemfile
         
     | 
| 
       244 
     | 
    
         
            -
            - gemfiles/rails_6.1.gemfile
         
     | 
| 
       245 
236 
     | 
    
         
             
            - gemfiles/rails_7.0.gemfile
         
     | 
| 
      
 237 
     | 
    
         
            +
            - gemfiles/rails_7.1.gemfile
         
     | 
| 
      
 238 
     | 
    
         
            +
            - gemfiles/rails_7.2.gemfile
         
     | 
| 
      
 239 
     | 
    
         
            +
            - gemfiles/rails_8.0.gemfile
         
     | 
| 
      
 240 
     | 
    
         
            +
            - gemfiles/rails_8.1.gemfile
         
     | 
| 
       246 
241 
     | 
    
         
             
            - lib/generators/shinq/worker/templates/create_table_migration.erb
         
     | 
| 
       247 
242 
     | 
    
         
             
            - lib/generators/shinq/worker/templates/worker.erb
         
     | 
| 
       248 
243 
     | 
    
         
             
            - lib/generators/shinq/worker/worker_generator.rb
         
     | 
| 
         @@ -269,7 +264,6 @@ homepage: https://github.com/ryopeko/shinq 
     | 
|
| 
       269 
264 
     | 
    
         
             
            licenses:
         
     | 
| 
       270 
265 
     | 
    
         
             
            - MIT
         
     | 
| 
       271 
266 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       272 
     | 
    
         
            -
            post_install_message: 
         
     | 
| 
       273 
267 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       274 
268 
     | 
    
         
             
            require_paths:
         
     | 
| 
       275 
269 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -284,8 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       284 
278 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       285 
279 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       286 
280 
     | 
    
         
             
            requirements: []
         
     | 
| 
       287 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       288 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 281 
     | 
    
         
            +
            rubygems_version: 3.6.2
         
     | 
| 
       289 
282 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       290 
283 
     | 
    
         
             
            summary: Worker and enqueuer for Q4M using the interface of ActiveJob.
         
     | 
| 
       291 
284 
     | 
    
         
             
            test_files:
         
     |