dashing-rails 2.6.1 → 2.6.2

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: 8dfddde01d385b4094caeb1dfa91d57eb3661695
4
- data.tar.gz: f7afc786e36b73efdd1cd121818fe3dc3fb3f7dc
3
+ metadata.gz: 06cc63083d02f095ae16feb5e29521f4b448cc97
4
+ data.tar.gz: bef8bbb5ca30a5ebe0449c3544ace81d8457017a
5
5
  SHA512:
6
- metadata.gz: ec6a9a63a1191a23eea315b6e22b6eb4b58045c9f5d6d8f2de73340f0c49deb1eefcdc53b6e0f3fa2351c04f61c020b556d8f85e608f43cfcdf0577c2742450b
7
- data.tar.gz: e4146726fc36bc5e96d4cf2251d9d811387ea41e1ddffed1d9932375ca2d8be24c706618492b863ad9433fe07581fb38dd9430102119ccad6ff8ffa5fc659123
6
+ metadata.gz: 9f940073cb5fe34b9a6b9664f893b57824309fb1a83c88a247d6e2bcb60d10f6a0e2a5f06fb1f5e06c12d809cf2346780321aeb1b20033514e52eadbd516d395
7
+ data.tar.gz: 49874d2f0102b44446b38beb7af8fa0fa3340067424838012fe8c8409bc4a6a55f3c0a09366e0693bf2c084fab753ac37be9fb22b9313615005bd99bbe7026ef
@@ -1,3 +1,8 @@
1
+ ## 2.6.2
2
+
3
+ * Stop using connection pool wrapper as per the documentation [https://github.com/gottfrois/dashing-rails/pull/103](https://github.com/gottfrois/dashing-rails/pull/103)
4
+
5
+
1
6
  ## 2.6.1
2
7
 
3
8
  * Revert gridster dashing to a newer version
data/README.md CHANGED
@@ -30,8 +30,8 @@ Key features:
30
30
 
31
31
  ## Requirements
32
32
 
33
- * Ruby >=1.9.3
34
- * Rails 4
33
+ * Ruby >= 1.9.3
34
+ * Rails >= 4
35
35
  * Redis
36
36
  * Multi Threaded server ([puma](https://github.com/puma/puma), [rainbows](http://rainbows.rubyforge.org/))
37
37
 
@@ -148,8 +148,11 @@ dashing_events.*
148
148
  where `*` can be anything. This give you all the flexibility you need to push to redis. For example the `send_event` method provided by Dashing uses the following namespace:
149
149
 
150
150
  ```ruby
151
- redis.publish("dashing_events.create", {})
151
+ redis.with do |redis_connection|
152
+ redis_connection.publish("dashing_events.create", {})
153
+ end
152
154
  ```
155
+ (where `redis_connection` is a redis connection from a connection pooler.)
153
156
 
154
157
  You can configure the redis namespace in `config/initializers/dashing.rb`:
155
158
 
@@ -3,26 +3,31 @@ module Dashing
3
3
  include ActionController::Live
4
4
 
5
5
  def index
6
+ @redis = Dashing.redis
7
+
6
8
  response.headers['Content-Type'] = 'text/event-stream'
7
9
  response.headers['X-Accel-Buffering'] = 'no'
8
10
  response.stream.write latest_events
9
11
 
10
- @redis = Dashing.redis
11
- @redis.psubscribe("#{Dashing.config.redis_namespace}.*") do |on|
12
- on.pmessage do |pattern, event, data|
13
- response.stream.write("data: #{data}\n\n")
12
+ @redis.with do |redis_connection|
13
+ redis_connection.psubscribe("#{Dashing.config.redis_namespace}.*") do |on|
14
+ on.pmessage do |pattern, event, data|
15
+ response.stream.write("data: #{data}\n\n")
16
+ end
14
17
  end
15
18
  end
16
19
  rescue IOError
17
20
  logger.info "[Dashing][#{Time.now.utc.to_s}] Stream closed"
18
21
  ensure
19
- @redis.quit
22
+ @redis.shutdown { |redis_connection| redis_connection.quit }
20
23
  response.stream.close
21
24
  end
22
25
 
23
26
  def latest_events
24
- events = Dashing.redis.hvals("#{Dashing.config.redis_namespace}.latest")
25
- events.map { |v| "data: #{v}\n\n" }.join
27
+ @redis.with do |redis_connection|
28
+ events = redis_connection.hvals("#{Dashing.config.redis_namespace}.latest")
29
+ events.map { |v| "data: #{v}\n\n" }.join
30
+ end
26
31
  end
27
32
  end
28
33
  end
@@ -14,7 +14,9 @@ module Dashing
14
14
  def update
15
15
  data = params[:widget] || {}
16
16
  hash = data.merge(id: params[:name], updatedAt: Time.now.utc.to_i)
17
- Dashing.redis.publish("#{Dashing.config.redis_namespace}.create", hash.to_json)
17
+ Dashing.redis.with do |redis_connection|
18
+ redis_connection.publish("#{Dashing.config.redis_namespace}.create", hash.to_json)
19
+ end
18
20
 
19
21
  render nothing: true
20
22
  end
@@ -20,8 +20,10 @@ module Dashing
20
20
 
21
21
  def send_event(id, data)
22
22
  event = data.merge(id: id, updatedAt: Time.now.utc.to_i).to_json
23
- redis.hset("#{Dashing.config.redis_namespace}.latest", id, event)
24
- redis.publish("#{Dashing.config.redis_namespace}.create", event)
23
+ redis.with do |redis_connection|
24
+ redis_connection.hset("#{Dashing.config.redis_namespace}.latest", id, event)
25
+ redis_connection.publish("#{Dashing.config.redis_namespace}.create", event)
26
+ end
25
27
  end
26
28
 
27
29
  end
@@ -43,7 +43,7 @@ module Dashing
43
43
  end
44
44
 
45
45
  def redis
46
- @redis ||= ::ConnectionPool::Wrapper.new(size: request_thread_count, timeout: redis_timeout) { new_redis_connection }
46
+ @redis ||= ::ConnectionPool.new(size: request_thread_count, timeout: redis_timeout) { new_redis_connection }
47
47
  end
48
48
 
49
49
  def new_redis_connection
@@ -21,8 +21,10 @@ module Dashing
21
21
  if defined?(::PhusionPassenger)
22
22
  ::PhusionPassenger.on_event(:starting_worker_process) do |forked|
23
23
  if forked
24
- ::Dashing.redis.client.disconnect
25
- ::Dashing.redis.client.connect
24
+ ::Dashing.redis.with do |redis_connection|
25
+ redis_connection.client.disconnect
26
+ redis_connection.client.connect
27
+ end
26
28
  end
27
29
  end
28
30
  end
@@ -1,3 +1,3 @@
1
1
  module Dashing
2
- VERSION = '2.6.1'
2
+ VERSION = '2.6.2'
3
3
  end
@@ -1,9 +1,10 @@
1
1
  RSpec.describe Dashing::WidgetsController do
2
2
 
3
3
  let(:redis) { double }
4
+ let(:redis_connection) { double }
4
5
 
5
6
  before do
6
- stub_redis(redis)
7
+ stub_redis_with_connection(redis, redis_connection)
7
8
  @routes = Dashing::Engine.routes
8
9
  end
9
10
 
@@ -49,7 +50,7 @@ RSpec.describe Dashing::WidgetsController do
49
50
  context 'when valid' do
50
51
 
51
52
  before do
52
- expect(redis).to receive(:publish)
53
+ expect(redis_connection).to receive(:publish)
53
54
  end
54
55
 
55
56
  it 'responds success' do
@@ -4,7 +4,8 @@ RSpec.describe Dashing::Configuration do
4
4
 
5
5
  it { expect(instance.engine_path).to eq('/dashing') }
6
6
  # it { expect(instance.scheduler).to be_a(::Rufus::Scheduler.new) }
7
- it { expect(instance.redis).to be_a(::Redis) }
7
+ it { expect(instance.redis).to be_a(::ConnectionPool) }
8
+ it { instance.redis.with { |r| expect(r).to be_a(::Redis) } }
8
9
 
9
10
  # Redis
10
11
  it { expect(instance.redis_host).to eq('127.0.0.1') }
@@ -6,4 +6,9 @@ module ControllerSpecHelpers
6
6
  def stub_redis(stubbed_redis)
7
7
  allow(Dashing.config).to receive(:redis).and_return(stubbed_redis)
8
8
  end
9
+
10
+ def stub_redis_with_connection(stubbed_redis, stubbed_redis_connection)
11
+ stub_redis(stubbed_redis)
12
+ allow(stubbed_redis).to receive(:with).and_yield(stubbed_redis_connection)
13
+ end
9
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashing-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-Louis Gottfrois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-17 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.5.2
319
+ rubygems_version: 2.6.13
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: The exceptionally handsome dashboard framework for Rails.