fibered_mysql2 0.1.1 → 0.1.2
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/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -11
- data/lib/active_record/connection_adapters/fibered_mysql2_adapter.rb +13 -6
- data/lib/fibered_mysql2/version.rb +1 -1
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 03d7285011a1fd36ca7d030a233bdeb46900e44c512161abd0241c653b5cabd4
         | 
| 4 | 
            +
              data.tar.gz: 5ec6253f493c773a11207664df054dab32f5cfaf996fbb4706bb76d89cd04b1c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 890bb36f3cbd96021d0afa0d3ce06b1d02765afc8be3d7335d5b6234ec6b6e11b58a24b4b499d0332a2a01c778757dd5c880af6291e7f535a740e2da9be2ef62
         | 
| 7 | 
            +
              data.tar.gz: 0cc5c22298ca1bd4c6c443738b6aa1c306d412894141660f1ce49e4dc592474c172c014073b0a6e088506d3422c8983b21b00a9bd8bd018fd75a1b0904f33782
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). | |
| 4 4 |  | 
| 5 5 | 
             
            Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         | 
| 6 6 |  | 
| 7 | 
            +
            ## [0.1.2] - 2021-06-16
         | 
| 8 | 
            +
            ### Fixed
         | 
| 9 | 
            +
            - Added checking to be certain that @owner is never overwritten with a non-Fiber by another mixin.
         | 
| 10 | 
            +
             | 
| 7 11 | 
             
            ## [0.1.1] - 2021-02-12
         | 
| 8 12 | 
             
            ### Fixed
         | 
| 9 13 | 
             
            - Fixed bug with Rails 5+ adapter where connections that have `steal!` called on them were not having their owner updated to the current Fiber, which would then cause an exception when trying to expire the connection (this showed up with the Rails 5 `ConnectionPool::Reaper` that reaps unused connections)
         | 
| @@ -19,5 +23,6 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0 | |
| 19 23 | 
             
            - Added TravisCI unit test pipeline.
         | 
| 20 24 | 
             
            - Added coverage reports via Coveralls.
         | 
| 21 25 |  | 
| 26 | 
            +
            [0.1.2]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.1..v0.1.2
         | 
| 22 27 | 
             
            [0.1.1]: https://github.com/Invoca/fibered_mysql2/compare/v0.1.0..v0.1.1
         | 
| 23 28 | 
             
            [0.1.0]: https://github.com/Invoca/fibered_mysql2/tree/v0.1.0
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -8,6 +8,7 @@ gemspec | |
| 8 8 | 
             
            gem 'appraisal'
         | 
| 9 9 | 
             
            gem 'bundler',    '~> 1.8'
         | 
| 10 10 | 
             
            gem 'coveralls', require: false
         | 
| 11 | 
            +
            gem 'mimemagic',  '~> 0.3',     git: 'git@github.com:Invoca/mimemagic',                      ref: 'b084ce8d50c080f5a312156498be21a541fe72a2'
         | 
| 11 12 | 
             
            gem 'mysql2',     '0.4.5'
         | 
| 12 13 | 
             
            gem 'pry',        '~> 0.13'
         | 
| 13 14 | 
             
            gem 'pry-byebug', '~> 3.9'
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 | 
            +
            GIT
         | 
| 2 | 
            +
              remote: git@github.com:Invoca/mimemagic
         | 
| 3 | 
            +
              revision: b084ce8d50c080f5a312156498be21a541fe72a2
         | 
| 4 | 
            +
              ref: b084ce8d50c080f5a312156498be21a541fe72a2
         | 
| 5 | 
            +
              specs:
         | 
| 6 | 
            +
                mimemagic (0.3.5)
         | 
| 7 | 
            +
             | 
| 1 8 | 
             
            PATH
         | 
| 2 9 | 
             
              remote: .
         | 
| 3 10 | 
             
              specs:
         | 
| 4 | 
            -
                fibered_mysql2 (0.1. | 
| 11 | 
            +
                fibered_mysql2 (0.1.2)
         | 
| 5 12 | 
             
                  em-synchrony (~> 1.0)
         | 
| 6 13 | 
             
                  rails (>= 4.2, < 7)
         | 
| 7 14 |  | 
| @@ -63,14 +70,14 @@ GEM | |
| 63 70 | 
             
                  minitest (~> 5.1)
         | 
| 64 71 | 
             
                  tzinfo (~> 1.1)
         | 
| 65 72 | 
             
                  zeitwerk (~> 2.2, >= 2.2.2)
         | 
| 66 | 
            -
                appraisal (2. | 
| 73 | 
            +
                appraisal (2.4.0)
         | 
| 67 74 | 
             
                  bundler
         | 
| 68 75 | 
             
                  rake
         | 
| 69 76 | 
             
                  thor (>= 0.14.0)
         | 
| 70 77 | 
             
                builder (3.2.4)
         | 
| 71 78 | 
             
                byebug (11.1.3)
         | 
| 72 79 | 
             
                coderay (1.1.3)
         | 
| 73 | 
            -
                concurrent-ruby (1.1. | 
| 80 | 
            +
                concurrent-ruby (1.1.8)
         | 
| 74 81 | 
             
                coveralls (0.8.23)
         | 
| 75 82 | 
             
                  json (>= 1.8, < 3)
         | 
| 76 83 | 
             
                  simplecov (~> 0.16.1)
         | 
| @@ -82,14 +89,14 @@ GEM | |
| 82 89 | 
             
                docile (1.3.2)
         | 
| 83 90 | 
             
                em-synchrony (1.0.6)
         | 
| 84 91 | 
             
                  eventmachine (>= 1.0.0.beta.1)
         | 
| 85 | 
            -
                erubi (1. | 
| 92 | 
            +
                erubi (1.10.0)
         | 
| 86 93 | 
             
                eventmachine (1.2.7)
         | 
| 87 94 | 
             
                globalid (0.4.2)
         | 
| 88 95 | 
             
                  activesupport (>= 4.2.0)
         | 
| 89 | 
            -
                i18n (1.8. | 
| 96 | 
            +
                i18n (1.8.7)
         | 
| 90 97 | 
             
                  concurrent-ruby (~> 1.0)
         | 
| 91 98 | 
             
                json (2.3.1)
         | 
| 92 | 
            -
                loofah (2. | 
| 99 | 
            +
                loofah (2.8.0)
         | 
| 93 100 | 
             
                  crass (~> 1.0.2)
         | 
| 94 101 | 
             
                  nokogiri (>= 1.5.9)
         | 
| 95 102 | 
             
                mail (2.7.1)
         | 
| @@ -97,10 +104,9 @@ GEM | |
| 97 104 | 
             
                marcel (0.3.3)
         | 
| 98 105 | 
             
                  mimemagic (~> 0.3.2)
         | 
| 99 106 | 
             
                method_source (1.0.0)
         | 
| 100 | 
            -
                mimemagic (0.3.5)
         | 
| 101 107 | 
             
                mini_mime (1.0.2)
         | 
| 102 108 | 
             
                mini_portile2 (2.4.0)
         | 
| 103 | 
            -
                minitest (5.14. | 
| 109 | 
            +
                minitest (5.14.3)
         | 
| 104 110 | 
             
                mysql2 (0.4.5)
         | 
| 105 111 | 
             
                nio4r (2.5.4)
         | 
| 106 112 | 
             
                nokogiri (1.10.10)
         | 
| @@ -173,12 +179,12 @@ GEM | |
| 173 179 | 
             
                thread_safe (0.3.6)
         | 
| 174 180 | 
             
                tins (1.25.0)
         | 
| 175 181 | 
             
                  sync
         | 
| 176 | 
            -
                tzinfo (1.2. | 
| 182 | 
            +
                tzinfo (1.2.9)
         | 
| 177 183 | 
             
                  thread_safe (~> 0.1)
         | 
| 178 184 | 
             
                websocket-driver (0.7.3)
         | 
| 179 185 | 
             
                  websocket-extensions (>= 0.1.0)
         | 
| 180 186 | 
             
                websocket-extensions (0.1.5)
         | 
| 181 | 
            -
                zeitwerk (2.4. | 
| 187 | 
            +
                zeitwerk (2.4.1)
         | 
| 182 188 |  | 
| 183 189 | 
             
            PLATFORMS
         | 
| 184 190 | 
             
              ruby
         | 
| @@ -188,6 +194,7 @@ DEPENDENCIES | |
| 188 194 | 
             
              bundler (~> 1.8)
         | 
| 189 195 | 
             
              coveralls
         | 
| 190 196 | 
             
              fibered_mysql2!
         | 
| 197 | 
            +
              mimemagic (~> 0.3)!
         | 
| 191 198 | 
             
              mysql2 (= 0.4.5)
         | 
| 192 199 | 
             
              pry (~> 0.13)
         | 
| 193 200 | 
             
              pry-byebug (~> 3.9)
         | 
| @@ -195,4 +202,4 @@ DEPENDENCIES | |
| 195 202 | 
             
              rspec (~> 3.0)
         | 
| 196 203 |  | 
| 197 204 | 
             
            BUNDLED WITH
         | 
| 198 | 
            -
               1.17. | 
| 205 | 
            +
               1.17.3
         | 
| @@ -20,10 +20,10 @@ module FiberedMysql2 | |
| 20 20 | 
             
                def lease
         | 
| 21 21 | 
             
                  if in_use?
         | 
| 22 22 | 
             
                    msg = "Cannot lease connection, ".dup
         | 
| 23 | 
            -
                    if  | 
| 23 | 
            +
                    if owner_fiber == Fiber.current
         | 
| 24 24 | 
             
                      msg << "it is already leased by the current fiber."
         | 
| 25 25 | 
             
                    else
         | 
| 26 | 
            -
                      msg << "it is already in use by a different fiber: #{ | 
| 26 | 
            +
                      msg << "it is already in use by a different fiber: #{owner_fiber}. " \
         | 
| 27 27 | 
             
                              "Current fiber: #{Fiber.current}."
         | 
| 28 28 | 
             
                    end
         | 
| 29 29 | 
             
                    raise ::ActiveRecord::ActiveRecordError, msg
         | 
| @@ -37,9 +37,9 @@ module FiberedMysql2 | |
| 37 37 | 
             
                    # Because we are actively releasing connections from dead fibers, we only want
         | 
| 38 38 | 
             
                    # to enforce that we're expiring the current fibers connection, iff the owner
         | 
| 39 39 | 
             
                    # of the connection is still alive.
         | 
| 40 | 
            -
                    if  | 
| 40 | 
            +
                    if owner_fiber.alive? && owner_fiber != Fiber.current
         | 
| 41 41 | 
             
                      raise ::ActiveRecord::ActiveRecordError, "Cannot expire connection, " \
         | 
| 42 | 
            -
                        "it is owned by a different fiber: #{ | 
| 42 | 
            +
                        "it is owned by a different fiber: #{owner_fiber}. " \
         | 
| 43 43 | 
             
                        "Current fiber: #{Fiber.current}."
         | 
| 44 44 | 
             
                    end
         | 
| 45 45 |  | 
| @@ -52,8 +52,8 @@ module FiberedMysql2 | |
| 52 52 |  | 
| 53 53 | 
             
                def steal!
         | 
| 54 54 | 
             
                  if in_use?
         | 
| 55 | 
            -
                    if  | 
| 56 | 
            -
                      pool.send :remove_connection_from_thread_cache, self,  | 
| 55 | 
            +
                    if owner_fiber != Fiber.current
         | 
| 56 | 
            +
                      pool.send :remove_connection_from_thread_cache, self, owner_fiber
         | 
| 57 57 |  | 
| 58 58 | 
             
                      @owner = Fiber.current
         | 
| 59 59 | 
             
                    end
         | 
| @@ -61,6 +61,13 @@ module FiberedMysql2 | |
| 61 61 | 
             
                    raise ::ActiveRecord::ActiveRecordError, "Cannot steal connection, it is not currently leased."
         | 
| 62 62 | 
             
                  end
         | 
| 63 63 | 
             
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                private
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                def owner_fiber
         | 
| 68 | 
            +
                  @owner.is_a?(Fiber) or raise "@owner must be a Fiber! Found #{@owner.inspect}"
         | 
| 69 | 
            +
                  @owner
         | 
| 70 | 
            +
                end
         | 
| 64 71 | 
             
              end
         | 
| 65 72 |  | 
| 66 73 | 
             
              class FiberedMysql2Adapter < ::ActiveRecord::ConnectionAdapters::EMMysql2Adapter
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fibered_mysql2
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Invoca Development
         | 
| 8 | 
            -
            autorequire:
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-06-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: em-synchrony
         | 
| @@ -44,7 +44,7 @@ dependencies: | |
| 44 44 | 
             
                - - "<"
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 46 | 
             
                    version: '7'
         | 
| 47 | 
            -
            description:
         | 
| 47 | 
            +
            description: 
         | 
| 48 48 | 
             
            email:
         | 
| 49 49 | 
             
            - development@invoca.com
         | 
| 50 50 | 
             
            executables: []
         | 
| @@ -77,7 +77,7 @@ licenses: [] | |
| 77 77 | 
             
            metadata:
         | 
| 78 78 | 
             
              allowed_push_host: https://rubygems.org
         | 
| 79 79 | 
             
              homepage_uri: https://github.com/Invoca/fibered_mysql2
         | 
| 80 | 
            -
            post_install_message:
         | 
| 80 | 
            +
            post_install_message: 
         | 
| 81 81 | 
             
            rdoc_options: []
         | 
| 82 82 | 
             
            require_paths:
         | 
| 83 83 | 
             
            - lib
         | 
| @@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 93 93 | 
             
                  version: '0'
         | 
| 94 94 | 
             
            requirements: []
         | 
| 95 95 | 
             
            rubygems_version: 3.0.1
         | 
| 96 | 
            -
            signing_key:
         | 
| 96 | 
            +
            signing_key: 
         | 
| 97 97 | 
             
            specification_version: 4
         | 
| 98 98 | 
             
            summary: An adapter for fibered mysql2
         | 
| 99 99 | 
             
            test_files: []
         |