chillout 0.8.3 → 0.8.4
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/lib/chillout.rb +8 -4
- data/lib/chillout/creation_listener.rb +2 -3
- data/lib/chillout/middleware/creations_monitor.rb +3 -3
- data/lib/chillout/middleware/sidekiq.rb +1 -2
- data/lib/chillout/version.rb +1 -1
- data/test/chillout_test.rb +8 -0
- data/test/integration/creations_monitor_rack_test.rb +3 -3
- data/test/middleware/creations_monitor_test.rb +1 -1
- metadata +3 -4
- data/lib/chillout/custom_metric.rb +0 -27
- data/test/custom_metric_test.rb +0 -15
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8308f094f935ed83592a06a45fe6b15dfc32fb7a
         | 
| 4 | 
            +
              data.tar.gz: 2a23cac7e8d85f95ebf6f6fb5ba82cd531d3cc45
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b1d901f3d22ec457782f8376c30851b338779a2c3f63be2753213ecb111b215f4ed034084f78956db9411a80d6cb123bad0a0ada315da8dc66cf168085755fc9
         | 
| 7 | 
            +
              data.tar.gz: 2848b76d928fa80ed56d8633b791744c5c5fe24d43c727570e5543b83c644aef0d3783daebc3ea612b5d1294108fd7159267fc8577f7133919994cc12e35b473
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/chillout.rb
    CHANGED
    
    | @@ -1,16 +1,21 @@ | |
| 1 1 | 
             
            require "chillout/version"
         | 
| 2 2 | 
             
            require "chillout/config"
         | 
| 3 | 
            +
            require "chillout/creations_container"
         | 
| 3 4 | 
             
            require "chillout/middleware/creations_monitor"
         | 
| 4 5 | 
             
            require "chillout/integrations/sidekiq"
         | 
| 5 6 | 
             
            require "chillout/subscribers/action_controller_notifications"
         | 
| 6 7 | 
             
            require "chillout/server_side/dispatcher"
         | 
| 7 8 | 
             
            require "chillout/server_side/server_side"
         | 
| 8 9 | 
             
            require "chillout/server_side/http_client"
         | 
| 9 | 
            -
            require "chillout/custom_metric"
         | 
| 10 10 | 
             
            require "chillout/client"
         | 
| 11 11 |  | 
| 12 12 | 
             
            module Chillout
         | 
| 13 | 
            -
              Metric | 
| 13 | 
            +
              module Metric
         | 
| 14 | 
            +
                def self.track(name)
         | 
| 15 | 
            +
                  Chillout.creations ||= CreationsContainer.new
         | 
| 16 | 
            +
                  Chillout.creations.increment!(name)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 14 19 |  | 
| 15 20 | 
             
              def self.creations
         | 
| 16 21 | 
             
                Thread.current[:creations]
         | 
| @@ -21,5 +26,4 @@ module Chillout | |
| 21 26 | 
             
              end
         | 
| 22 27 | 
             
            end
         | 
| 23 28 |  | 
| 24 | 
            -
            require 'chillout/railtie' if defined?(Rails)
         | 
| 25 | 
            -
             | 
| 29 | 
            +
            require 'chillout/railtie' if defined?(Rails)
         | 
| @@ -12,9 +12,8 @@ module Chillout | |
| 12 12 | 
             
                  class_name = monitored_class.name
         | 
| 13 13 | 
             
                  monitored_class.after_commit :on => :create do
         | 
| 14 14 | 
             
                    Rails.logger.debug "[Chillout] Model created: #{class_name}"
         | 
| 15 | 
            -
                     | 
| 16 | 
            -
                    creations | 
| 17 | 
            -
                    creations.increment!(class_name)
         | 
| 15 | 
            +
                    Chillout.creations ||= CreationsContainer.new
         | 
| 16 | 
            +
                    Chillout.creations.increment!(class_name)
         | 
| 18 17 | 
             
                  end
         | 
| 19 18 | 
             
                end
         | 
| 20 19 | 
             
              end
         | 
| @@ -14,10 +14,10 @@ module Chillout | |
| 14 14 | 
             
                    status, headers, body = @app.call(env)
         | 
| 15 15 | 
             
                    return status, headers, body
         | 
| 16 16 | 
             
                  ensure
         | 
| 17 | 
            -
                    if  | 
| 17 | 
            +
                    if creations = Chillout.creations
         | 
| 18 18 | 
             
                      @client.logger.debug "Non-empty creations container found"
         | 
| 19 | 
            -
                      @client.enqueue( | 
| 20 | 
            -
                       | 
| 19 | 
            +
                      @client.enqueue(creations)
         | 
| 20 | 
            +
                      Chillout.creations = nil
         | 
| 21 21 | 
             
                    end
         | 
| 22 22 |  | 
| 23 23 | 
             
                    body.close if body && body.respond_to?(:close) && $!
         | 
    
        data/lib/chillout/version.rb
    CHANGED
    
    
| @@ -16,9 +16,9 @@ module Chillout | |
| 16 16 | 
             
                def app
         | 
| 17 17 | 
             
                  client = @client
         | 
| 18 18 | 
             
                  deepest_level = lambda do |env|
         | 
| 19 | 
            -
                     | 
| 20 | 
            -
                     | 
| 21 | 
            -
                     | 
| 19 | 
            +
                    Chillout.creations = CreationsContainer.new
         | 
| 20 | 
            +
                    Chillout.creations.increment!("User", 2)
         | 
| 21 | 
            +
                    Chillout.creations.increment!("Cart",3 )
         | 
| 22 22 | 
             
                    [200, env, ['hello']]
         | 
| 23 23 | 
             
                  end
         | 
| 24 24 | 
             
                  Rack::Builder.new do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: chillout
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.8. | 
| 4 | 
            +
              version: 0.8.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Michal Lomnicki
         | 
| @@ -206,7 +206,6 @@ files: | |
| 206 206 | 
             
            - lib/chillout/config.rb
         | 
| 207 207 | 
             
            - lib/chillout/creation_listener.rb
         | 
| 208 208 | 
             
            - lib/chillout/creations_container.rb
         | 
| 209 | 
            -
            - lib/chillout/custom_metric.rb
         | 
| 210 209 | 
             
            - lib/chillout/generators/install.rb
         | 
| 211 210 | 
             
            - lib/chillout/integrations/sidekiq.rb
         | 
| 212 211 | 
             
            - lib/chillout/job.rb
         | 
| @@ -228,10 +227,10 @@ files: | |
| 228 227 | 
             
            - test/acceptance/client_sends_metrics_test.rb
         | 
| 229 228 | 
             
            - test/acceptance/sidekiq_workers_send_metrics_test.rb
         | 
| 230 229 | 
             
            - test/check_result_test.rb
         | 
| 230 | 
            +
            - test/chillout_test.rb
         | 
| 231 231 | 
             
            - test/client_test.rb
         | 
| 232 232 | 
             
            - test/config_test.rb
         | 
| 233 233 | 
             
            - test/creations_container_test.rb
         | 
| 234 | 
            -
            - test/custom_metric_test.rb
         | 
| 235 234 | 
             
            - test/dispatcher_test.rb
         | 
| 236 235 | 
             
            - test/http_client_test.rb
         | 
| 237 236 | 
             
            - test/integration/client_test.rb
         | 
| @@ -630,10 +629,10 @@ test_files: | |
| 630 629 | 
             
            - test/acceptance/client_sends_metrics_test.rb
         | 
| 631 630 | 
             
            - test/acceptance/sidekiq_workers_send_metrics_test.rb
         | 
| 632 631 | 
             
            - test/check_result_test.rb
         | 
| 632 | 
            +
            - test/chillout_test.rb
         | 
| 633 633 | 
             
            - test/client_test.rb
         | 
| 634 634 | 
             
            - test/config_test.rb
         | 
| 635 635 | 
             
            - test/creations_container_test.rb
         | 
| 636 | 
            -
            - test/custom_metric_test.rb
         | 
| 637 636 | 
             
            - test/dispatcher_test.rb
         | 
| 638 637 | 
             
            - test/http_client_test.rb
         | 
| 639 638 | 
             
            - test/integration/client_test.rb
         | 
| @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            require 'chillout/creations_container'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Chillout
         | 
| 4 | 
            -
              class CustomMetric
         | 
| 5 | 
            -
                def initialize(creations_container = nil)
         | 
| 6 | 
            -
                  @creations_container = creations_container
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def track(name)
         | 
| 10 | 
            -
                  creations_container.increment!(name)
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
               
         | 
| 13 | 
            -
                private
         | 
| 14 | 
            -
                def creations_container
         | 
| 15 | 
            -
                  if container_not_initialized?
         | 
| 16 | 
            -
                    Thread.current[:creations] ||= CreationsContainer.new
         | 
| 17 | 
            -
                    @creations_container = Thread.current[:creations]
         | 
| 18 | 
            -
                  else
         | 
| 19 | 
            -
                    @creations_container
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                def container_not_initialized?
         | 
| 24 | 
            -
                  @creations_container.nil?
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
            end
         | 
    
        data/test/custom_metric_test.rb
    DELETED
    
    | @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            require 'test_helper' 
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            class CustomMetricTest < ChilloutTestCase
         | 
| 4 | 
            -
              def setup
         | 
| 5 | 
            -
                @creations_container = MiniTest::Mock.new
         | 
| 6 | 
            -
              end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              def test_custom_creation
         | 
| 9 | 
            -
                @creations_container.expect(:nil?, false, [])
         | 
| 10 | 
            -
                @creations_container.expect(:increment!, nil, ['foo'])
         | 
| 11 | 
            -
                @custom_metric = Chillout::CustomMetric.new(@creations_container)
         | 
| 12 | 
            -
                @custom_metric.track('foo')
         | 
| 13 | 
            -
                @creations_container.verify
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         |